-
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.
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary This PR adds basic formatting for unary expressions. <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan I added a new `unary.py` with custom test cases
- Loading branch information
1 parent
3973836
commit 1336ca6
Showing
13 changed files
with
621 additions
and
113 deletions.
There are no files selected for viewing
138 changes: 138 additions & 0 deletions
138
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/unary.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,138 @@ | ||
if not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb: | ||
pass | ||
|
||
a = True | ||
not a | ||
|
||
b = 10 | ||
-b | ||
+b | ||
|
||
## Leading operand comments | ||
|
||
if not ( | ||
# comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
): | ||
pass | ||
|
||
|
||
if ~( | ||
# comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb): | ||
pass | ||
|
||
if -( | ||
# comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb): | ||
pass | ||
|
||
|
||
if +( | ||
# comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb): | ||
pass | ||
|
||
if ( | ||
not | ||
# comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
): | ||
pass | ||
|
||
|
||
if ( | ||
~ | ||
# comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb): | ||
pass | ||
|
||
if ( | ||
- | ||
# comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb): | ||
pass | ||
|
||
|
||
if ( | ||
+ | ||
# comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb): | ||
pass | ||
|
||
## Parentheses | ||
|
||
if ( | ||
# unary comment | ||
not | ||
# operand comment | ||
( | ||
# comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
) | ||
): | ||
pass | ||
|
||
if (not ( | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
) | ||
): | ||
pass | ||
|
||
if aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa & (not ( | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
) | ||
): | ||
pass | ||
|
||
if ( | ||
not ( | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
) | ||
& aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
): | ||
pass | ||
|
||
|
||
## Trailing operator comments | ||
|
||
if ( | ||
not # comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
): | ||
pass | ||
|
||
|
||
if ( | ||
~ # comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
): | ||
pass | ||
|
||
if ( | ||
- # comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
): | ||
pass | ||
|
||
|
||
if ( | ||
+ # comment | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
): | ||
pass | ||
|
||
|
||
## Varia | ||
|
||
if not \ | ||
a: | ||
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
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.