-
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.
Visit deferred lambdas before type definitions (#9540)
## Summary This is effectively the same problem as #9175. And this just papers over it again, though I'm gonna try a more holistic fix in a follow-up PR. The _real_ fix here is that we need to continue to visit deferred items until they're exhausted since, e.g., we still get this case wrong (flagging `re` as unused): ```python import re cast(lambda: re.match, 1) ``` Closes #9534.
- Loading branch information
1 parent
b983ab1
commit da275b8
Showing
4 changed files
with
14 additions
and
1 deletion.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_21.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,8 @@ | ||
from __future__ import annotations | ||
|
||
from collections import Counter | ||
from typing import cast | ||
|
||
|
||
def get_most_common_fn(k): | ||
return lambda c: cast(Counter, c).most_common(k) |
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
...er/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_21.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_linter/src/rules/pyflakes/mod.rs | ||
--- | ||
|