-
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.
[
flake8-pyi
] - add autofix for future-annotations-in-stub
(`PYI04…
…4`) (#12676) ## Summary add autofix for `PYI044` ## Test Plan `cargo test`
- Loading branch information
1 parent
5499821
commit 7b5fd63
Showing
5 changed files
with
99 additions
and
10 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI044.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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# Bad import. | ||
from __future__ import annotations # PYI044. | ||
from __future__ import annotations, with_statement # PYI044. | ||
|
||
# Good imports. | ||
from __future__ import Something | ||
from __future__ import with_statement | ||
import sys | ||
from socket import AF_INET |
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
38 changes: 38 additions & 0 deletions
38
...ake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI044_PYI044.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,38 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs | ||
--- | ||
PYI044.pyi:2:1: PYI044 [*] `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics | ||
| | ||
1 | # Bad import. | ||
2 | from __future__ import annotations # PYI044. | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI044 | ||
3 | from __future__ import annotations, with_statement # PYI044. | ||
| | ||
= help: Remove `from __future__ import annotations` | ||
|
||
ℹ Safe fix | ||
1 1 | # Bad import. | ||
2 |-from __future__ import annotations # PYI044. | ||
3 2 | from __future__ import annotations, with_statement # PYI044. | ||
4 3 | | ||
5 4 | # Good imports. | ||
|
||
PYI044.pyi:3:1: PYI044 [*] `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics | ||
| | ||
1 | # Bad import. | ||
2 | from __future__ import annotations # PYI044. | ||
3 | from __future__ import annotations, with_statement # PYI044. | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI044 | ||
4 | | ||
5 | # Good imports. | ||
| | ||
= help: Remove `from __future__ import annotations` | ||
|
||
ℹ Safe fix | ||
1 1 | # Bad import. | ||
2 2 | from __future__ import annotations # PYI044. | ||
3 |-from __future__ import annotations, with_statement # PYI044. | ||
3 |+from __future__ import with_statement # PYI044. | ||
4 4 | | ||
5 5 | # Good imports. | ||
6 6 | from __future__ import with_statement |