-
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.
Avoid using typing-imported symbols for runtime edits
- Loading branch information
1 parent
28a5e60
commit ae6e441
Showing
12 changed files
with
192 additions
and
61 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_10.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 typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from sys import exit as bar | ||
|
||
|
||
def main(): | ||
exit(0) |
File renamed without changes.
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,10 @@ | ||
from __future__ import annotations | ||
|
||
import typing | ||
|
||
if typing.TYPE_CHECKING: | ||
from collections import defaultdict | ||
|
||
|
||
def f(x: typing.DefaultDict[str, str]) -> 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,8 @@ | ||
import typing | ||
|
||
if typing.TYPE_CHECKING: | ||
from collections import defaultdict | ||
|
||
|
||
def f(x: typing.DefaultDict[str, str]) -> 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
12 changes: 12 additions & 0 deletions
12
.../src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_10.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,12 @@ | ||
--- | ||
source: crates/ruff/src/rules/pylint/mod.rs | ||
--- | ||
sys_exit_alias_10.py:8:5: PLR1722 Use `sys.exit()` instead of `exit` | ||
| | ||
8 | def main(): | ||
9 | exit(0) | ||
| ^^^^ PLR1722 | ||
| | ||
= help: Replace `exit` with `sys.exit()` | ||
|
||
|
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
20 changes: 20 additions & 0 deletions
20
crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_1.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,20 @@ | ||
--- | ||
source: crates/ruff/src/rules/pyupgrade/mod.rs | ||
--- | ||
UP006_1.py:9:10: UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation | ||
| | ||
9 | def f(x: typing.DefaultDict[str, str]) -> None: | ||
| ^^^^^^^^^^^^^^^^^^ UP006 | ||
10 | ... | ||
| | ||
= help: Replace with `collections.defaultdict` | ||
|
||
ℹ Suggested fix | ||
6 6 | from collections import defaultdict | ||
7 7 | | ||
8 8 | | ||
9 |-def f(x: typing.DefaultDict[str, str]) -> None: | ||
9 |+def f(x: defaultdict[str, str]) -> None: | ||
10 10 | ... | ||
|
||
|
12 changes: 12 additions & 0 deletions
12
crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_2.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,12 @@ | ||
--- | ||
source: crates/ruff/src/rules/pyupgrade/mod.rs | ||
--- | ||
UP006_2.py:7:10: UP006 Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation | ||
| | ||
7 | def f(x: typing.DefaultDict[str, str]) -> None: | ||
| ^^^^^^^^^^^^^^^^^^ UP006 | ||
8 | ... | ||
| | ||
= help: Replace with `collections.defaultdict` | ||
|
||
|
Oops, something went wrong.