-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
4bdd99f
commit 71c25e4
Showing
10 changed files
with
187 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 4 additions & 9 deletions
13
crates/ruff_python_formatter/src/pattern/pattern_match_value.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.