Conversation
|
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
PR Check ResultsBenchmarkLinuxWindows |
b1591ba to
73a6595
Compare
StmtMatch and MatchCaseStmtMatch
| [block_indent(&format_args![ | ||
| text("case"), | ||
| space(), | ||
| not_yet_implemented_custom_text("NOT_YET_IMPLEMENTED_MatchCase"), | ||
| text(":"), | ||
| block_indent(&case.body.format()) | ||
| ])] |
There was a problem hiding this comment.
Temporary until the MatchCase formatting is implemented.
| match ( | ||
| # leading expr comment |
There was a problem hiding this comment.
This seems to be a known issue where the comment right next to an opening parentheses is moved down instead.
- match ( # leading expr comment
+ match (
+ # leading expr comment| )?; | ||
|
|
||
| for case in cases { | ||
| write!( |
There was a problem hiding this comment.
Do we need to retain empty lines between match cases?
Micha trying to write valid python code 😅
match test:
case "a":
pass
case "b":
passThere was a problem hiding this comment.
I think the newline handling will be done in the MatchCase implementation. Any newline between the match statement and the first case will be removed as is done in black as well:
match test:
case "a":
pass
# vvvvv
match test:
case "a":
passe34d757 to
16fc898
Compare
| enclosing: enclosing_node, | ||
| preceding: self.preceding_node, | ||
| following: Some(node), | ||
| parent: self.parents.iter().rev().nth(1).copied(), |
| [ | ||
| text("case"), | ||
| space(), | ||
| not_yet_implemented_custom_text("NOT_YET_IMPLEMENTED_Pattern"), |
There was a problem hiding this comment.
We can also do this as a separate PR: Ideally, we call into pattern.format() here. This requires implementing AsFormat and IntoFormat for Pattern, similar to how it is done for Mod
ruff/crates/ruff_python_formatter/src/module/mod.rs
Lines 1 to 35 in f45e864
There was a problem hiding this comment.
Yes, it's already a work in progress in the next PR (https://github.com/astral-sh/ruff/pull/6360/files#diff-05760c9829e7694c86aaf97014143c0785c12da546f06dcfbc87caf67b15d773) ;)
## Summary This PR adds support for `StmtMatch` with subs for `MatchCase`. ## Test Plan Add a few additional test cases around `match` statement, comments, line breaks. resolves: astral-sh#6298

Summary
This PR adds support for
StmtMatchwith subs forMatchCase.Test Plan
Add a few additional test cases around
matchstatement, comments, line breaks.resolves: #6298