-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statementtopic-reachabilityDetecting unreachable codeDetecting unreachable code
Description
Bug Report
When using a match
statement with case
s that are constants, it incorrectly identifies the later cases as being unreachable.
To Reproduce
I have the following file structure:
project_root
util
__init__.py
consts.py
test.py
In consts.py
:
BLANK = ""
SPECIAL = "asdf"
In test.py
:
from util import consts
def test_func(test_str: str) -> str:
match test_str:
case consts.BLANK:
return "blank"
case consts.SPECIAL:
return "special"
case _:
return "other"
Expected Behavior
mypy
succeeds as the code is reachable.
Actual Behavior
Running mypy --warn-unreachable .\util\test.py
gives:
util\test.py:9: error: Statement is unreachable
util\test.py:11: error: Statement is unreachable
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 0.942
- Mypy command-line flags:
--warn-unreachable
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.10
- Operating system and version: Windows 10
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statementtopic-reachabilityDetecting unreachable codeDetecting unreachable code