-
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.
## Summary Checks for the presence of unused private `typing.TypeAlias` definitions. ref #848 ## Test Plan Snapshots and manual runs of flake8
- Loading branch information
1 parent
047c211
commit 7838d8c
Showing
9 changed files
with
160 additions
and
0 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,22 @@ | ||
import typing | ||
import sys | ||
from typing import TypeAlias | ||
|
||
|
||
_UnusedPrivateTypeAlias: TypeAlias = int | None | ||
_T: typing.TypeAlias = str | ||
|
||
# OK | ||
_UsedPrivateTypeAlias: TypeAlias = int | None | ||
|
||
def func(arg: _UsedPrivateTypeAlias) -> _UsedPrivateTypeAlias: | ||
... | ||
|
||
|
||
if sys.version_info > (3, 9): | ||
_PrivateTypeAlias: TypeAlias = str | None | ||
else: | ||
_PrivateTypeAlias: TypeAlias = float | None | ||
|
||
|
||
def func2(arg: _PrivateTypeAlias) -> 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import typing | ||
import sys | ||
from typing import TypeAlias | ||
|
||
|
||
_UnusedPrivateTypeAlias: TypeAlias = int | None | ||
_T: typing.TypeAlias = str | ||
|
||
# OK | ||
_UsedPrivateTypeAlias: TypeAlias = int | None | ||
|
||
def func(arg: _UsedPrivateTypeAlias) -> _UsedPrivateTypeAlias: | ||
... | ||
|
||
|
||
if sys.version_info > (3, 9): | ||
_PrivateTypeAlias: TypeAlias = str | None | ||
else: | ||
_PrivateTypeAlias: TypeAlias = float | None | ||
|
||
|
||
def func2(arg: _PrivateTypeAlias) -> 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
4 changes: 4 additions & 0 deletions
4
...ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI047_PYI047.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,4 @@ | ||
--- | ||
source: crates/ruff/src/rules/flake8_pyi/mod.rs | ||
--- | ||
|
20 changes: 20 additions & 0 deletions
20
...uff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI047_PYI047.pyi.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,20 @@ | ||
--- | ||
source: crates/ruff/src/rules/flake8_pyi/mod.rs | ||
--- | ||
PYI047.pyi:6:1: PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used | ||
| | ||
6 | _UnusedPrivateTypeAlias: TypeAlias = int | None | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ PYI047 | ||
7 | _T: typing.TypeAlias = str | ||
| | ||
|
||
PYI047.pyi:7:1: PYI047 Private TypeAlias `_T` is never used | ||
| | ||
6 | _UnusedPrivateTypeAlias: TypeAlias = int | None | ||
7 | _T: typing.TypeAlias = str | ||
| ^^ PYI047 | ||
8 | | ||
9 | # OK | ||
| | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.