-
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.
- Loading branch information
1 parent
0ad0df0
commit eaf2a35
Showing
3 changed files
with
34 additions
and
73 deletions.
There are no files selected for viewing
74 changes: 6 additions & 68 deletions
74
...f_linter/resources/test/fixtures/wemake_python_styleguide/control_var_used_after_block.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 |
---|---|---|
@@ -1,70 +1,8 @@ | ||
import typing | ||
from typing import cast | ||
|
||
for global_var in []: | ||
_ = global_var | ||
for x in []: | ||
_ = x | ||
pass | ||
|
||
_ = global_var | ||
|
||
def foo(): | ||
# For control var used outside block | ||
for event in []: | ||
_ = event | ||
pass | ||
|
||
_ = event | ||
|
||
for x in range(10): | ||
pass | ||
|
||
# Usage in another block | ||
for y in range(10): | ||
# x is used outside of the loop it was defined in (meant to use y) | ||
if x == 5: | ||
pass | ||
|
||
# Tuple destructuring | ||
for a, b, c in []: | ||
_ = a | ||
_ = b | ||
_ = c | ||
pass | ||
|
||
_ = a | ||
_ = b | ||
_ = c | ||
|
||
# Array destructuring | ||
for [d, e, f] in []: | ||
_ = d | ||
_ = e | ||
_ = f | ||
pass | ||
|
||
_ = d | ||
_ = e | ||
_ = f | ||
|
||
# with statement | ||
with None as w: | ||
_ = w | ||
pass | ||
|
||
_ = w | ||
|
||
# Nested blocks | ||
with None as q: | ||
_ = q | ||
|
||
for n in []: | ||
_ = n | ||
_ = q | ||
pass | ||
|
||
_ = n | ||
|
||
_ = q | ||
_ = n | ||
|
||
|
||
# Using the same control variable name in a different loop is ok | ||
for x in []: | ||
_ = x | ||
pass |
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