Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent
used-before-assignment
in pattern matching with a guard
- Loading branch information
1 parent
e7ef1fd
commit 46c2f90
Showing
4 changed files
with
16 additions
and
0 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 ``used-before-assignment`` in pattern matching | ||
with a guard. | ||
|
||
Closes #5327 |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""Tests for used-before-assignment with python 3.10's pattern matching""" | ||
|
||
match ("example", "one"): | ||
case (x, y) if x == "example": | ||
print("x used to cause used-before-assignment!") | ||
case _: | ||
print("good thing it doesn't now!") |
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.10 |