-
-
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.
Co-authored-by: detachhead <detachhead@users.noreply.github.com> Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
- Loading branch information
1 parent
fbc9e66
commit f5e168e
Showing
8 changed files
with
96 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Fix false positive for ``undefined-loop-variable`` in ``for-else`` loops that use a function | ||
having a return type annotation of ``NoReturn`` or ``Never``. | ||
|
||
Closes #7311 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
undefined-loop-variable:6:11:6:14:do_stuff:Using possibly undefined loop variable 'var':UNDEFINED | ||
undefined-loop-variable:25:7:25:11::Using possibly undefined loop variable 'var1':UNDEFINED | ||
undefined-loop-variable:75:11:75:14:do_stuff_with_redefined_range:Using possibly undefined loop variable 'var':UNDEFINED | ||
undefined-loop-variable:181:11:181:20:find_even_number:Using possibly undefined loop variable 'something':UNDEFINED | ||
undefined-loop-variable:14:11:14:14:do_stuff:Using possibly undefined loop variable 'var':UNDEFINED | ||
undefined-loop-variable:33:7:33:11::Using possibly undefined loop variable 'var1':UNDEFINED | ||
undefined-loop-variable:83:11:83:14:do_stuff_with_redefined_range:Using possibly undefined loop variable 'var':UNDEFINED | ||
undefined-loop-variable:201:11:201:20:find_even_number:Using possibly undefined loop variable 'something':UNDEFINED |
17 changes: 17 additions & 0 deletions
17
tests/functional/u/undefined/undefined_loop_variable_py311.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,17 @@ | ||
"""Tests for undefined-loop-variable using Python 3.11 syntax.""" | ||
|
||
from typing import Never | ||
|
||
|
||
def for_else_never(iterable): | ||
"""Test for-else with Never type.""" | ||
|
||
def idontreturn() -> Never: | ||
"""This function never returns.""" | ||
|
||
while True: | ||
for thing in iterable: | ||
break | ||
else: | ||
idontreturn() | ||
print(thing) |
2 changes: 2 additions & 0 deletions
2
tests/functional/u/undefined/undefined_loop_variable_py311.rc
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,2 @@ | ||
[testoptions] | ||
min_pyver=3.11 |