-
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.
fix(rules): skip dummy variables for
PLR1704
(#12190)
## Summary Resolves #12157. ## Test Plan Snapshot tests.
- Loading branch information
1 parent
e2e0889
commit 2f3264e
Showing
3 changed files
with
67 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,11 @@ def func(a): | |
print(a) | ||
|
||
|
||
def func(_): | ||
for _ in range(1): | ||
... | ||
|
||
|
||
# Errors | ||
def func(a): | ||
for a in range(1): | ||
|
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
120 changes: 59 additions & 61 deletions
120
...napshots/ruff_linter__rules__pylint__tests__PLR1704_redefined_argument_from_local.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,115 +1,113 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pylint/mod.rs | ||
--- | ||
redefined_argument_from_local.py:26:9: PLR1704 Redefining argument with the local name `a` | ||
redefined_argument_from_local.py:31:9: PLR1704 Redefining argument with the local name `a` | ||
| | ||
24 | # Errors | ||
25 | def func(a): | ||
26 | for a in range(1): | ||
29 | # Errors | ||
30 | def func(a): | ||
31 | for a in range(1): | ||
| ^ PLR1704 | ||
27 | ... | ||
32 | ... | ||
| | ||
|
||
redefined_argument_from_local.py:31:9: PLR1704 Redefining argument with the local name `i` | ||
redefined_argument_from_local.py:36:9: PLR1704 Redefining argument with the local name `i` | ||
| | ||
30 | def func(i): | ||
31 | for i in range(10): | ||
35 | def func(i): | ||
36 | for i in range(10): | ||
| ^ PLR1704 | ||
32 | print(i) | ||
37 | print(i) | ||
| | ||
|
||
redefined_argument_from_local.py:38:25: PLR1704 Redefining argument with the local name `e` | ||
redefined_argument_from_local.py:43:25: PLR1704 Redefining argument with the local name `e` | ||
| | ||
36 | try: | ||
37 | ... | ||
38 | except Exception as e: | ||
41 | try: | ||
42 | ... | ||
43 | except Exception as e: | ||
| ^ PLR1704 | ||
39 | print(e) | ||
44 | print(e) | ||
| | ||
|
||
redefined_argument_from_local.py:43:24: PLR1704 Redefining argument with the local name `f` | ||
redefined_argument_from_local.py:48:24: PLR1704 Redefining argument with the local name `f` | ||
| | ||
42 | def func(f): | ||
43 | with open('', ) as f: | ||
47 | def func(f): | ||
48 | with open('', ) as f: | ||
| ^ PLR1704 | ||
44 | print(f) | ||
49 | print(f) | ||
| | ||
|
||
redefined_argument_from_local.py:48:24: PLR1704 Redefining argument with the local name `a` | ||
redefined_argument_from_local.py:53:24: PLR1704 Redefining argument with the local name `a` | ||
| | ||
47 | def func(a, b): | ||
48 | with context() as (a, b, c): | ||
52 | def func(a, b): | ||
53 | with context() as (a, b, c): | ||
| ^ PLR1704 | ||
49 | print(a, b, c) | ||
54 | print(a, b, c) | ||
| | ||
|
||
redefined_argument_from_local.py:48:27: PLR1704 Redefining argument with the local name `b` | ||
redefined_argument_from_local.py:53:27: PLR1704 Redefining argument with the local name `b` | ||
| | ||
47 | def func(a, b): | ||
48 | with context() as (a, b, c): | ||
52 | def func(a, b): | ||
53 | with context() as (a, b, c): | ||
| ^ PLR1704 | ||
49 | print(a, b, c) | ||
54 | print(a, b, c) | ||
| | ||
|
||
redefined_argument_from_local.py:53:24: PLR1704 Redefining argument with the local name `a` | ||
redefined_argument_from_local.py:58:24: PLR1704 Redefining argument with the local name `a` | ||
| | ||
52 | def func(a, b): | ||
53 | with context() as [a, b, c]: | ||
57 | def func(a, b): | ||
58 | with context() as [a, b, c]: | ||
| ^ PLR1704 | ||
54 | print(a, b, c) | ||
59 | print(a, b, c) | ||
| | ||
|
||
redefined_argument_from_local.py:53:27: PLR1704 Redefining argument with the local name `b` | ||
redefined_argument_from_local.py:58:27: PLR1704 Redefining argument with the local name `b` | ||
| | ||
52 | def func(a, b): | ||
53 | with context() as [a, b, c]: | ||
57 | def func(a, b): | ||
58 | with context() as [a, b, c]: | ||
| ^ PLR1704 | ||
54 | print(a, b, c) | ||
59 | print(a, b, c) | ||
| | ||
|
||
redefined_argument_from_local.py:58:51: PLR1704 Redefining argument with the local name `a` | ||
redefined_argument_from_local.py:63:51: PLR1704 Redefining argument with the local name `a` | ||
| | ||
57 | def func(a): | ||
58 | with open('foo.py', ) as f, open('bar.py') as a: | ||
62 | def func(a): | ||
63 | with open('foo.py', ) as f, open('bar.py') as a: | ||
| ^ PLR1704 | ||
59 | ... | ||
64 | ... | ||
| | ||
|
||
redefined_argument_from_local.py:64:13: PLR1704 Redefining argument with the local name `a` | ||
redefined_argument_from_local.py:69:13: PLR1704 Redefining argument with the local name `a` | ||
| | ||
62 | def func(a): | ||
63 | def bar(b): | ||
64 | for a in range(1): | ||
67 | def func(a): | ||
68 | def bar(b): | ||
69 | for a in range(1): | ||
| ^ PLR1704 | ||
65 | print(a) | ||
70 | print(a) | ||
| | ||
|
||
redefined_argument_from_local.py:70:13: PLR1704 Redefining argument with the local name `b` | ||
redefined_argument_from_local.py:75:13: PLR1704 Redefining argument with the local name `b` | ||
| | ||
68 | def func(a): | ||
69 | def bar(b): | ||
70 | for b in range(1): | ||
73 | def func(a): | ||
74 | def bar(b): | ||
75 | for b in range(1): | ||
| ^ PLR1704 | ||
71 | print(b) | ||
76 | print(b) | ||
| | ||
|
||
redefined_argument_from_local.py:76:13: PLR1704 Redefining argument with the local name `a` | ||
redefined_argument_from_local.py:81:13: PLR1704 Redefining argument with the local name `a` | ||
| | ||
74 | def func(a=1): | ||
75 | def bar(b=2): | ||
76 | for a in range(1): | ||
79 | def func(a=1): | ||
80 | def bar(b=2): | ||
81 | for a in range(1): | ||
| ^ PLR1704 | ||
77 | print(a) | ||
78 | for b in range(1): | ||
82 | print(a) | ||
83 | for b in range(1): | ||
| | ||
|
||
redefined_argument_from_local.py:78:13: PLR1704 Redefining argument with the local name `b` | ||
redefined_argument_from_local.py:83:13: PLR1704 Redefining argument with the local name `b` | ||
| | ||
76 | for a in range(1): | ||
77 | print(a) | ||
78 | for b in range(1): | ||
81 | for a in range(1): | ||
82 | print(a) | ||
83 | for b in range(1): | ||
| ^ PLR1704 | ||
79 | print(b) | ||
84 | print(b) | ||
| | ||
|
||
|