-
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.
- Loading branch information
1 parent
4a1740a
commit 8ac7584
Showing
11 changed files
with
410 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import builtins | ||
import typing | ||
from typing import TypeAlias, Final | ||
|
||
field1: int | ||
field2: int = ... | ||
field3 = ... # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | ||
field4: int = 0 | ||
field41: int = 0xFFFFFFFF | ||
field42: int = 1234567890 | ||
field43: int = -0xFFFFFFFF | ||
field44: int = -1234567890 | ||
field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need type annotation for "field5" | ||
field6 = 0 # Y052 Need type annotation for "field6" | ||
field7 = b"" # Y052 Need type annotation for "field7" | ||
field71 = "foo" # Y052 Need type annotation for "field71" | ||
field72: str = "foo" | ||
field8 = False # Y052 Need type annotation for "field8" | ||
field81 = -1 # Y052 Need type annotation for "field81" | ||
field82: float = -98.43 | ||
field83 = -42j # Y052 Need type annotation for "field83" | ||
field84 = 5 + 42j # Y052 Need type annotation for "field84" | ||
field85 = -5 - 42j # Y052 Need type annotation for "field85" | ||
field9 = None # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "field9: TypeAlias = None" | ||
Field95: TypeAlias = None | ||
Field96: TypeAlias = int | None | ||
Field97: TypeAlias = None | typing.SupportsInt | builtins.str | float | bool | ||
field19 = [1, 2, 3] # Y052 Need type annotation for "field19" | ||
field191: list[int] = [1, 2, 3] | ||
field20 = (1, 2, 3) # Y052 Need type annotation for "field20" | ||
field201: tuple[int, ...] = (1, 2, 3) | ||
field21 = {1, 2, 3} # Y052 Need type annotation for "field21" | ||
field211: set[int] = {1, 2, 3} | ||
field212 = {"foo": "bar"} # Y052 Need type annotation for "field212" | ||
field213: dict[str, str] = {"foo": "bar"} | ||
field22: Final = {"foo": 5} | ||
field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments | ||
field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments | ||
field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments | ||
field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments | ||
field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments | ||
field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments | ||
field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments | ||
# When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node | ||
field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments | ||
field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments | ||
field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments | ||
field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments |
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,51 @@ | ||
import builtins | ||
import typing | ||
from typing import TypeAlias, Final | ||
|
||
# We shouldn't emit Y015 for simple default values | ||
field1: int | ||
field2: int = ... | ||
field3 = ... # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | ||
field4: int = 0 | ||
field41: int = 0xFFFFFFFF | ||
field42: int = 1234567890 | ||
field43: int = -0xFFFFFFFF | ||
field44: int = -1234567890 | ||
field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need type annotation for "field5" | ||
field6 = 0 # Y052 Need type annotation for "field6" | ||
field7 = b"" # Y052 Need type annotation for "field7" | ||
field71 = "foo" # Y052 Need type annotation for "field71" | ||
field72: str = "foo" | ||
field8 = False # Y052 Need type annotation for "field8" | ||
field81 = -1 # Y052 Need type annotation for "field81" | ||
field82: float = -98.43 | ||
field83 = -42j # Y052 Need type annotation for "field83" | ||
field84 = 5 + 42j # Y052 Need type annotation for "field84" | ||
field85 = -5 - 42j # Y052 Need type annotation for "field85" | ||
field9 = None # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "field9: TypeAlias = None" | ||
Field95: TypeAlias = None | ||
Field96: TypeAlias = int | None | ||
Field97: TypeAlias = None | typing.SupportsInt | builtins.str | float | bool | ||
field19 = [1, 2, 3] # Y052 Need type annotation for "field19" | ||
field191: list[int] = [1, 2, 3] | ||
field20 = (1, 2, 3) # Y052 Need type annotation for "field20" | ||
field201: tuple[int, ...] = (1, 2, 3) | ||
field21 = {1, 2, 3} # Y052 Need type annotation for "field21" | ||
field211: set[int] = {1, 2, 3} | ||
field212 = {"foo": "bar"} # Y052 Need type annotation for "field212" | ||
field213: dict[str, str] = {"foo": "bar"} | ||
field22: Final = {"foo": 5} | ||
|
||
# We *should* emit Y015 for more complex default values | ||
field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments | ||
field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments | ||
field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments | ||
field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments | ||
field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments | ||
field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments | ||
field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments | ||
# When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node | ||
field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments | ||
field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments | ||
field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments | ||
field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments |
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
6 changes: 6 additions & 0 deletions
6
...ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI015_PYI015.py.snap
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,6 @@ | ||
--- | ||
source: crates/ruff/src/rules/flake8_pyi/mod.rs | ||
expression: diagnostics | ||
--- | ||
[] | ||
|
Oops, something went wrong.