-
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.
Comments outside expression parentheses
- Loading branch information
Showing
12 changed files
with
589 additions
and
95 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
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
113 changes: 113 additions & 0 deletions
113
...hon_formatter/resources/test/fixtures/ruff/parentheses/expression_parentheses_comments.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,113 @@ | ||
list_with_parenthesized_elements1 = [ | ||
# comment leading outer | ||
( | ||
# comment leading inner | ||
1 + 2 # comment trailing inner | ||
) # comment trailing outer | ||
] | ||
|
||
list_with_parenthesized_elements2 = [ | ||
# leading outer | ||
(1 + 2) | ||
] | ||
list_with_parenthesized_elements3 = [ | ||
# leading outer | ||
(1 + 2) # trailing outer | ||
] | ||
list_with_parenthesized_elements4 = [ | ||
# leading outer | ||
(1 + 2), # trailing outer | ||
] | ||
list_with_parenthesized_elements5 = [ | ||
(1), # trailing outer | ||
(2), # trailing outer | ||
] | ||
|
||
nested_parentheses1 = ( | ||
( | ||
( | ||
1 | ||
) # i | ||
) # j | ||
) # k | ||
nested_parentheses2 = [ | ||
( | ||
( | ||
( | ||
1 | ||
) # i | ||
# i2 | ||
) # j | ||
# j2 | ||
) # k | ||
# k2 | ||
] | ||
nested_parentheses3 = ( | ||
( # a | ||
( # b | ||
1 | ||
) # i | ||
) # j | ||
) # k | ||
nested_parentheses4 = [ | ||
# a | ||
( # b | ||
# c | ||
( # d | ||
# e | ||
( #f | ||
1 | ||
) # i | ||
# i2 | ||
) # j | ||
# j2 | ||
) # k | ||
# k2 | ||
] | ||
|
||
|
||
x = ( | ||
# unary comment | ||
not | ||
# in-between comment | ||
( | ||
# leading inner | ||
"a" | ||
), | ||
not # in-between comment | ||
( | ||
# leading inner | ||
"b" | ||
), | ||
not | ||
( # in-between comment | ||
# leading inner | ||
"c" | ||
), | ||
# 1 | ||
not # 2 | ||
( # 3 | ||
# 4 | ||
"d" | ||
) | ||
) | ||
|
||
if ( | ||
# unary comment | ||
not | ||
# in-between comment | ||
( | ||
# leading inner | ||
1 | ||
) | ||
): | ||
pass | ||
|
||
# Make sure we keep a inside the parentheses | ||
# https://github.com/astral-sh/ruff/issues/7892 | ||
x = ( | ||
# a | ||
( # b | ||
1 | ||
) | ||
) |
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.