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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user