-
-
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.
…9645) (#9647) (cherry picked from commit 117be95) Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
- Loading branch information
1 parent
9dae975
commit aed496a
Showing
5 changed files
with
38 additions
and
7 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 a false positive for `possibly-used-before-assignment` when using | ||
`typing.assert_never()` (3.11+) to indicate exhaustiveness. | ||
|
||
Closes #9643 |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""assert_never() introduced in 3.11""" | ||
from enum import Enum | ||
from typing import assert_never | ||
|
||
|
||
class MyEnum(Enum): | ||
"""A lovely enum.""" | ||
VAL1 = 1 | ||
VAL2 = 2 | ||
|
||
|
||
def do_thing(val: MyEnum) -> None: | ||
"""Do a thing.""" | ||
if val is MyEnum.VAL1: | ||
note = 'got 1' | ||
elif val is MyEnum.VAL2: | ||
note = 'got 2' | ||
else: | ||
assert_never(val) | ||
|
||
print('Note:', note) |
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 |