mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-16 01:25:22 +00:00
Implement FormatPatternMatchValue
(#6799)
## Summary This is effectively #6608, but with additional tests. We aren't properly handling parenthesized patterns, but that needs to be dealt with separately as it's somewhat involved. Closes #6555
This commit is contained in:
parent
4bdd99f882
commit
71c25e4f9d
10 changed files with 189 additions and 407 deletions
|
@ -1,19 +1,14 @@
|
|||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use ruff_python_ast::PatternMatchValue;
|
||||
|
||||
use crate::{not_yet_implemented_custom_text, FormatNodeRule, PyFormatter};
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatPatternMatchValue;
|
||||
|
||||
impl FormatNodeRule<PatternMatchValue> for FormatPatternMatchValue {
|
||||
fn fmt_fields(&self, item: &PatternMatchValue, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
"\"NOT_YET_IMPLEMENTED_PatternMatchValue\"",
|
||||
item
|
||||
)]
|
||||
)
|
||||
// TODO(charlie): Avoid double parentheses for parenthesized top-level `PatternMatchValue`.
|
||||
let PatternMatchValue { value, range: _ } = item;
|
||||
value.format().fmt(f)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue