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:
Charlie Marsh 2023-08-23 10:01:14 -04:00 committed by GitHub
parent 4bdd99f882
commit 71c25e4f9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 189 additions and 407 deletions

View file

@ -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)
}
}