-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use BestFitParenthesize layout for literals and match as
- Loading branch information
1 parent
ca0ae0a
commit 94a294b
Showing
8 changed files
with
520 additions
and
34 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
.../ruff_python_formatter/resources/test/fixtures/ruff/pattern/pattern_maybe_parenthesize.py
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Patterns that use BestFit should be parenthesized if they exceed the configured line width | ||
# but fit within parentheses. | ||
match x: | ||
case ( | ||
"averyLongStringThatGetsParenthesizedOnceItExceedsTheConfiguredLineWidthFitsPar" | ||
): | ||
pass | ||
|
||
|
||
match x: | ||
case ( | ||
b"averyLongStringThatGetsParenthesizedOnceItExceedsTheConfiguredLineWidthFitsPa" | ||
): | ||
pass | ||
|
||
match x: | ||
case ( | ||
f"averyLongStringThatGetsParenthesizedOnceItExceedsTheConfiguredLineWidthFitsPa" | ||
): | ||
pass | ||
|
||
|
||
match x: | ||
case ( | ||
5444444444444444444444444444444444444444444444444444444444444444444444444444444j | ||
): | ||
pass | ||
|
||
|
||
match x: | ||
case ( | ||
5444444444444444444444444444444444444444444444444444444444444444444444444444444 | ||
): | ||
pass | ||
|
||
|
||
match x: | ||
case ( | ||
5.44444444444444444444444444444444444444444444444444444444444444444444444444444 | ||
): | ||
pass | ||
|
||
|
||
match x: | ||
case ( | ||
averyLongIdentThatGetsParenthesizedOnceItExceedsTheConfiguredLineWidthFitsParenth | ||
): | ||
pass | ||
|
||
|
||
# But they aren't parenthesized when they exceed the line length even parenthesized | ||
match x: | ||
case "averyLongStringThatGetsParenthesizedOnceItExceedsTheConfiguredLineWidthFitsParenthesized": | ||
pass | ||
|
||
|
||
match x: | ||
case b"averyLongStringThatGetsParenthesizedOnceItExceedsTheConfiguredLineWidthFitsParenthesized": | ||
pass | ||
|
||
match x: | ||
case f"averyLongStringThatGetsParenthesizedOnceItExceedsTheConfiguredLineWidthFitsParenthesized": | ||
pass | ||
|
||
|
||
match x: | ||
case 54444444444444444444444444444444444444444444444444444444444444444444444444444444444j: | ||
pass | ||
|
||
|
||
match x: | ||
case 5444444444444444444444444444444444444444444444444444444444444444444444444444444444: | ||
pass | ||
|
||
|
||
match x: | ||
case 5.444444444444444444444444444444444444444444444444444444444444444444444444444444444: | ||
pass | ||
|
||
|
||
match x: | ||
case averyLongIdentifierThatGetsParenthesizedOnceItExceedsTheConfiguredLineWidthFitsParenthesized: | ||
pass | ||
|
||
|
||
# It uses the Multiline layout when there's an alias. | ||
match x: | ||
case ( | ||
averyLongIdentifierThatGetsParenthesizedOnceItExceedsTheConfiguredLineWidthFitsParenthe as b | ||
): | ||
pass | ||
|
||
|
||
|
||
match x: | ||
case ( | ||
"an implicit concatenated" "string literal" "in a match case" "that goes over multiple lines" | ||
): | ||
pass | ||
|
||
|
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
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
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
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
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.