-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statement
Description
Bug Report
When checking the type field of a dtype with match, mypy 1.19.0 complains sbout some cases with error: Statement is unreachable.
It doesn't look like a numpy bug because swapping the order of the cases (eg. moving the int32 case to the top) it produces inconsistent results (eg. it generates 1 error instead of 2).
To Reproduce
import numpy as np
def f(dt: np.dtype) -> None:
match dt.type:
case np.float64:
print("f")
case np.int64:
print("i")
case np.int32:
print("i")
dt: np.dtype = np.dtype(np.float64)
f(dt)Expected Behavior
Mypy should not complain
Actual Behavior
kk.py:9: error: Statement is unreachable [unreachable]
print("i")
^~~~~~~~~~
kk.py:11: error: Statement is unreachable [unreachable]
print("i")
^~~~~~~~~~
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.19.0
- Mypy command-line flags:
mypy --warn-unreachable kk.py - Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.14.0
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statement