-
-
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.
Prevent
used-before-assignment
in pattern matching with a guard (#7922
) (#7923) (cherry picked from commit bc9f15f) Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
- Loading branch information
1 parent
1f84ed9
commit 4655b92
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 |