Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer splitting right hand side of assignments
- Loading branch information
1 parent
d0d88d9
commit e465bfc
Showing
16 changed files
with
924 additions
and
296 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...ormatter/resources/test/fixtures/ruff/statement/assignment_split_value_first.options.json
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,5 @@ | ||
[ | ||
{ | ||
"preview": "enabled" | ||
} | ||
] |
71 changes: 71 additions & 0 deletions
71
...f_python_formatter/resources/test/fixtures/ruff/statement/assignment_split_value_first.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,71 @@ | ||
# Don't parenthesize the value because the target's trailing comma forces it to split. | ||
a[ | ||
aaaaaaa, | ||
b, | ||
] = cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc # comment | ||
|
||
# Parenthesize the value, but don't duplicate the comment. | ||
a[ | ||
aaaaaaa, | ||
b | ||
] = cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc # comment | ||
|
||
# Format both as flat, but don't loos the comment. | ||
a[ | ||
aaaaaaa, | ||
b | ||
] = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb # comment | ||
|
||
####################################################### | ||
# Test the case where a parenthesized value now fits: | ||
a[ | ||
aaaaaaa, | ||
b | ||
] = ( | ||
cccccccc # comment | ||
) | ||
|
||
# Doesn't use `BestFit` because the target always breaks because of the trailing comma | ||
a[ | ||
aaaaaaa, | ||
b, | ||
] = ( | ||
cccccccc # comment | ||
) | ||
|
||
# Doesn't use `BestFit` because the target always breaks because of the trailing comma | ||
# The group breaks because of its comments | ||
a[ | ||
aaaaaaa, | ||
b | ||
] = ( | ||
# leading comment | ||
b | ||
) = ( | ||
cccccccc # comment | ||
) | ||
|
||
|
||
a[bbbbbbbbbbbbbbbbbb] = ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc | ||
|
||
# Does not double-parenthesize tuples | ||
( | ||
first_item, | ||
second_item, | ||
) = some_looooooooong_module.some_loooooog_function_name( | ||
first_argument, second_argument, third_argument | ||
) | ||
|
||
|
||
# Preserve parentheses around the first target | ||
( | ||
req["ticket"]["steps"]["step"][0]["tasks"]["task"]["fields"]["field"][ | ||
"access_request" | ||
]["destinations"]["destination"][0]["ip_address"] | ||
) = dst | ||
|
||
( | ||
req["ticket"]["steps"]["step"][0]["tasks"]["task"]["fields"]["field"][ | ||
"access_request" | ||
]["destinations"]["destination"][0]["ip_address"] | ||
) += dst |
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.