-
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.
Don't treat annotations as redefinitions in
.pyi
files (#10512)
## Summary In #10341, we fixed some false positives in `.pyi` files, but introduced others. This PR effectively reverts the change in #10341 and fixes it in a slightly different way. Instead of changing the _bindings_ we generate in the semantic model in `.pyi` files, we instead change how we _resolve_ them. Closes #10509.
- Loading branch information
1 parent
60fd98e
commit caa1450
Showing
5 changed files
with
40 additions
and
8 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
crates/ruff_linter/resources/test/fixtures/pyflakes/F811_29.pyi
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 @@ | ||
"""Regression test for: https://github.com/astral-sh/ruff/issues/10509""" | ||
|
||
from foo import Bar as Bar | ||
|
||
class Eggs: | ||
Bar: int # OK | ||
|
||
Bar = 1 # F811 |
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
11 changes: 11 additions & 0 deletions
11
...r/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_29.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,11 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
--- | ||
F811_29.pyi:8:1: F811 Redefinition of unused `Bar` from line 3 | ||
| | ||
6 | Bar: int # OK | ||
7 | | ||
8 | Bar = 1 # F811 | ||
| ^^^ F811 | ||
| | ||
= help: Remove definition: `Bar` |
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