-
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.
Treat all
singledispatch
arguments as runtime-required (#11523)
## Summary It turns out that `singledispatch` does end up evaluating all arguments, even though only the first is used to dispatch. Closes #11520.
- Loading branch information
1 parent
ebdaf57
commit 52c946a
Showing
3 changed files
with
38 additions
and
19 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
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
32 changes: 15 additions & 17 deletions
32
...rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.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 |
---|---|---|
@@ -1,27 +1,25 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs | ||
--- | ||
singledispatch.py:10:20: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | ||
singledispatch.py:11:20: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block | ||
| | ||
8 | from numpy.typing import ArrayLike | ||
9 | from scipy.sparse import spmatrix | ||
10 | from pandas import DataFrame | ||
9 | from numpy.typing import ArrayLike | ||
10 | from scipy.sparse import spmatrix | ||
11 | from pandas import DataFrame | ||
| ^^^^^^^^^ TCH002 | ||
11 | | ||
12 | if TYPE_CHECKING: | ||
12 | | ||
13 | if TYPE_CHECKING: | ||
| | ||
= help: Move into type-checking block | ||
|
||
ℹ Unsafe fix | ||
7 7 | from numpy import asarray | ||
8 8 | from numpy.typing import ArrayLike | ||
9 9 | from scipy.sparse import spmatrix | ||
10 |-from pandas import DataFrame | ||
11 10 | | ||
12 11 | if TYPE_CHECKING: | ||
12 |+ from pandas import DataFrame | ||
13 13 | from numpy import ndarray | ||
14 14 | | ||
8 8 | from numpy import asarray | ||
9 9 | from numpy.typing import ArrayLike | ||
10 10 | from scipy.sparse import spmatrix | ||
11 |-from pandas import DataFrame | ||
12 11 | | ||
13 12 | if TYPE_CHECKING: | ||
13 |+ from pandas import DataFrame | ||
14 14 | from numpy import ndarray | ||
15 15 | | ||
|
||
|
||
16 16 | |