-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parenthesize long type annotations in annotated assignment statements
- Loading branch information
1 parent
ef4bd8d
commit 95130ad
Showing
9 changed files
with
789 additions
and
47 deletions.
There are no files selected for viewing
157 changes: 157 additions & 0 deletions
157
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/long_type_annotations.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,157 @@ | ||
x1: A[b] | EventHandler | EventSpec | list[EventHandler | EventSpec] | Other | More | AndMore | None = None | ||
|
||
x2: "VeryLongClassNameWithAwkwardGenericSubtype[int] |" "VeryLongClassNameWithAwkwardGenericSubtype[str]" | ||
|
||
x6: VeryLongClassNameWithAwkwardGenericSubtype[ | ||
integeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeer, | ||
VeryLongClassNameWithAwkwardGenericSubtype, | ||
str | ||
] = True | ||
|
||
|
||
x7: CustomTrainingJob | CustomContainerTrainingJob | CustomPythonPackageTrainingJob | ||
x8: ( | ||
None | ||
| datasets.ImageDataset | ||
| datasets.TabularDataset | ||
| datasets.TextDataset | ||
| datasets.VideoDataset | ||
) = None | ||
|
||
x9: None | ( | ||
datasets.ImageDataset | ||
| datasets.TabularDataset | ||
| datasets.TextDataset | ||
| datasets.VideoDataset | ||
) = None | ||
|
||
|
||
x10: ( | ||
aaaaaaaaaaaaaaaaaaaaaaaa[ | ||
bbbbbbbbbbb, | ||
Subscript | ||
| None | ||
| datasets.ImageDataset | ||
| datasets.TabularDataset | ||
| datasets.TextDataset | ||
| datasets.VideoDataset, | ||
], | ||
bbb[other], | ||
) = None | ||
|
||
x11: None | [ | ||
datasets.ImageDataset, | ||
datasets.TabularDataset, | ||
datasets.TextDataset, | ||
datasets.VideoDataset, | ||
] = None | ||
|
||
x12: None | [ | ||
datasets.ImageDataset, | ||
datasets.TabularDataset, | ||
datasets.TextDataset, | ||
datasets.VideoDataset, | ||
] | Other = None | ||
|
||
|
||
x13: [ | ||
datasets.ImageDataset, | ||
datasets.TabularDataset, | ||
datasets.TextDataset, | ||
datasets.VideoDataset, | ||
] | Other = None | ||
|
||
x14: [ | ||
datasets.ImageDataset, | ||
datasets.TabularDataset, | ||
datasets.TextDataset, | ||
datasets.VideoDataset, | ||
] | [ | ||
datasets.ImageDataset, | ||
datasets.TabularDataset, | ||
datasets.TextDataset, | ||
datasets.VideoDataset, | ||
] = None | ||
|
||
x15: [ | ||
datasets.ImageDataset, | ||
datasets.TabularDataset, | ||
datasets.TextDataset, | ||
datasets.VideoDataset, | ||
] | [ | ||
datasets.ImageDataset, | ||
datasets.TabularDataset, | ||
datasets.TextDataset, | ||
datasets.VideoDataset, | ||
] | Other = None | ||
|
||
x16: None | Literal[ | ||
"split", | ||
"a bit longer", | ||
"records", | ||
"index", | ||
"table", | ||
"columns", | ||
"values", | ||
] = None | ||
|
||
x17: None | [ | ||
datasets.ImageDataset, | ||
datasets.TabularDataset, | ||
datasets.TextDataset, | ||
datasets.VideoDataset, | ||
] | ||
|
||
|
||
class Test: | ||
safe_age: Decimal # the user's age, used to determine if it's safe for them to use ruff | ||
applied_fixes: int # the number of fixes that this user applied. Used for ranking the users with the most applied fixes. | ||
string_annotation: "Test" # a long comment after a quoted, runtime-only type annotation | ||
|
||
|
||
########## | ||
# Comments | ||
|
||
leading: ( | ||
# Leading comment | ||
None | dataset.ImageDataset | ||
) | ||
|
||
leading_with_value: ( | ||
# Leading comment | ||
None | ||
| dataset.ImageDataset | ||
) = None | ||
|
||
leading_open_parentheses: ( # Leading comment | ||
None | ||
| dataset.ImageDataset | ||
) | ||
|
||
leading_open_parentheses_with_value: ( # Leading comment | ||
None | ||
| dataset.ImageDataset | ||
) = None | ||
|
||
trailing: ( | ||
None | dataset.ImageDataset # trailing comment | ||
) | ||
|
||
trailing_with_value: ( | ||
None | dataset.ImageDataset # trailing comment | ||
) = None | ||
|
||
trailing_own_line: ( | ||
None | dataset.ImageDataset | ||
# trailing own line | ||
) | ||
|
||
trailing_own_line_with_value: ( | ||
None | dataset.ImageDataset | ||
# trailing own line | ||
) = None | ||
|
||
nested_comment: None | [ | ||
# a list of strings | ||
str | ||
] = None |
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.