-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[optional ext] Emit redefined-loop-name
for redefinitions of loop variables in body
#5649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jacobtylerwalls
merged 38 commits into
pylint-dev:main
from
jacobtylerwalls:redefined-loop-var
May 2, 2022
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
a80ad9f
Fix #5608: Emit `redefined-outer-name` for redefinitions of loop vari…
jacobtylerwalls fa33c2e
Extend solution to AugAssign
jacobtylerwalls 859b01e
Merge branch 'main' into redefined-loop-var
jacobtylerwalls 5929ce7
Update tests
jacobtylerwalls 91e118a
Fix false positive involving functions nested under loops
jacobtylerwalls 5b61d0a
Apply suggestions from code review
jacobtylerwalls c80336d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 506c194
Update test results
jacobtylerwalls a67f984
Remove is_message_enabled() call
jacobtylerwalls e6791e2
Create `redefined-loop-name` message
jacobtylerwalls 05dc2df
Update redefined-outer-name description
jacobtylerwalls 45987bb
Merge branch 'main' into redefined-loop-var
jacobtylerwalls 75f98a9
Make `redefined-loop-name` an optional extension
jacobtylerwalls 7147199
Delete relocated code
jacobtylerwalls c6e9766
Remove moved message description
jacobtylerwalls 46e0f59
Remove disables
jacobtylerwalls 8378199
Bump message ID
jacobtylerwalls 19962f6
Add examples
jacobtylerwalls c2b5d4e
Merge branch 'main' into redefined-loop-var
jacobtylerwalls b5c6aa5
Add pylintrc
jacobtylerwalls 09705bd
Add coverage and fix preexisting false positive
jacobtylerwalls 5970936
Add coverage
jacobtylerwalls cb3cfbf
Merge branch 'main' into redefined-loop-var
jacobtylerwalls f15d662
Apply suggestions from code review
jacobtylerwalls 3cc7f0a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3fb8477
Use self.linter.config and remove test file artifact
jacobtylerwalls 86a272e
Merge branch 'redefined-loop-var' of https://github.com/jacobtylerwal…
jacobtylerwalls e6e4834
Move to checker utils
jacobtylerwalls 0c23bdf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d2b487c
typo
jacobtylerwalls 0f67bc9
Fix typing
jacobtylerwalls 2824a1e
Better names
jacobtylerwalls d506334
Add caching
jacobtylerwalls 7c13e3a
keep scope() around
jacobtylerwalls efc734f
more specific type
jacobtylerwalls e21a932
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3990ee6
Remove now unused list
jacobtylerwalls 836ef8a
Fix existing typo
jacobtylerwalls File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,7 @@ | ||
function-redefined:18:4:18:15:AAAA.method2:method already defined line 15:UNDEFINED | ||
function-redefined:21:0:21:10:AAAA:class already defined line 8:UNDEFINED | ||
function-redefined:35:0:35:9:func2:function already defined line 32:UNDEFINED | ||
redefined-outer-name:37:4:37:16:func2:Redefining name '__revision__' from outer scope (line 7):UNDEFINED | ||
redefined-outer-name:37:4:37:16:func2:Redefining name '__revision__' from outer scope or loop (line 7):UNDEFINED | ||
function-redefined:54:4:54:23:exclusive_func2:function already defined line 48:UNDEFINED | ||
function-redefined:89:0:89:8:ceil:function already defined line 88:UNDEFINED | ||
function-redefined:93:0:93:8:math:function already defined line 92:UNDEFINED |
This file contains hidden or 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,2 +1,2 @@ | ||
invalid-name:7:0:7:5::"Constant name ""value"" doesn't conform to UPPER_CASE naming style":HIGH | ||
redefined-outer-name:12:4:12:9:clobbering:Redefining name 'value' from outer scope (line 7):UNDEFINED | ||
redefined-outer-name:12:4:12:9:clobbering:Redefining name 'value' from outer scope or loop (line 7):UNDEFINED |
This file contains hidden or 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 +1 @@ | ||
redefined-outer-name:4:4:6:20::Redefining name 'item' from outer scope (line 2):UNDEFINED | ||
redefined-outer-name:4:4:6:20::Redefining name 'item' from outer scope or loop (line 2):UNDEFINED |
This file contains hidden or 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,4 +1,4 @@ | ||
redefined-outer-name:11:4:12:12::Redefining name 'err' from outer scope (line 8):UNDEFINED | ||
redefined-outer-name:57:8:58:16::Redefining name 'err' from outer scope (line 51):UNDEFINED | ||
redefined-outer-name:11:4:12:12::Redefining name 'err' from outer scope or loop (line 8):UNDEFINED | ||
redefined-outer-name:57:8:58:16::Redefining name 'err' from outer scope or loop (line 51):UNDEFINED | ||
used-before-assignment:69:14:69:29:func:Using variable 'CustomException' before assignment:HIGH | ||
redefined-outer-name:71:4:72:12:func:Redefining name 'CustomException' from outer scope (line 62):UNDEFINED | ||
redefined-outer-name:71:4:72:12:func:Redefining name 'CustomException' from outer scope or loop (line 62):UNDEFINED |
This file contains hidden or 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,15 @@ | ||
"""Tests for redefinitions of loop variables inside the loop body. | ||
|
||
See: https://github.com/PyCQA/pylint/issues/5608 | ||
""" | ||
# pylint: disable=invalid-name | ||
|
||
lines = ["1\t", "2\t"] | ||
for line in lines: | ||
line = line.strip() # [redefined-outer-name] | ||
|
||
jacobtylerwalls marked this conversation as resolved.
Show resolved
Hide resolved
|
||
lines = [(1, "1\t"), (2, "2\t")] | ||
for i, line in lines: | ||
line = line.strip() # [redefined-outer-name] | ||
|
||
line = "no warning" |
This file contains hidden or 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,2 @@ | ||
redefined-outer-name:9:4:9:8::Redefining name 'line' from outer scope or loop (line 8):UNDEFINED | ||
redefined-outer-name:13:4:13:8::Redefining name 'line' from outer scope or loop (line 12):UNDEFINED |
This file contains hidden or 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 hidden or 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,4 +1,4 @@ | ||
redefined-outer-name:7:4:8:16::Redefining name 'i' from outer scope (line 6):UNDEFINED | ||
redefined-outer-name:12:4:13:25::Redefining name 'i' from outer scope (line 11):UNDEFINED | ||
redefined-outer-name:17:4:18:25::Redefining name 'i' from outer scope (line 16):UNDEFINED | ||
redefined-outer-name:22:4:23:25::Redefining name 'a' from outer scope (line 21):UNDEFINED | ||
redefined-outer-name:7:4:8:16::Redefining name 'i' from outer scope or loop (line 6):UNDEFINED | ||
redefined-outer-name:12:4:13:25::Redefining name 'i' from outer scope or loop (line 11):UNDEFINED | ||
redefined-outer-name:17:4:18:25::Redefining name 'i' from outer scope or loop (line 16):UNDEFINED | ||
redefined-outer-name:22:4:23:25::Redefining name 'a' from outer scope or loop (line 21):UNDEFINED |
This file contains hidden or 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 +1 @@ | ||
redefined-outer-name:4:4:5:16::Redefining name 'j' from outer scope (line 3):UNDEFINED | ||
redefined-outer-name:4:4:5:16::Redefining name 'j' from outer scope or loop (line 3):UNDEFINED |
This file contains hidden or 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 hidden or 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 hidden or 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,7 @@ | ||
used-before-assignment:7:7:7:8:used_before_assignment_1:Using variable 'x' before assignment:HIGH | ||
redefined-outer-name:8:12:8:13:used_before_assignment_1:Redefining name 'x' from outer scope (line 3):UNDEFINED | ||
redefined-outer-name:8:12:8:13:used_before_assignment_1:Redefining name 'x' from outer scope or loop (line 3):UNDEFINED | ||
used-before-assignment:13:7:13:8:used_before_assignment_2:Using variable 'x' before assignment:HIGH | ||
redefined-outer-name:15:4:15:5:used_before_assignment_2:Redefining name 'x' from outer scope (line 3):UNDEFINED | ||
redefined-outer-name:15:4:15:5:used_before_assignment_2:Redefining name 'x' from outer scope or loop (line 3):UNDEFINED | ||
used-before-assignment:19:7:19:8:used_before_assignment_3:Using variable 'x' before assignment:HIGH | ||
redefined-outer-name:21:12:21:13:used_before_assignment_3:Redefining name 'x' from outer scope (line 3):UNDEFINED | ||
redefined-outer-name:30:4:30:5:not_used_before_assignment_2:Redefining name 'x' from outer scope (line 3):UNDEFINED | ||
redefined-outer-name:21:12:21:13:used_before_assignment_3:Redefining name 'x' from outer scope or loop (line 3):UNDEFINED | ||
redefined-outer-name:30:4:30:5:not_used_before_assignment_2:Redefining name 'x' from outer scope or loop (line 3):UNDEFINED |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.