You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exhaustiveness checking false positives when using match self or match self.value inside an Enum #15186
When using match self or match self.value inside a method or property on an Enum, mypy reports an error on assert_never(). This works as expected in pyright.
main.py:17: error: Argument 1 to "assert_never" has incompatible type "MyEnum"; expected "NoReturn" [arg-type]
main.py:27: error: Argument 1 to "assert_never" has incompatible type "Union[str, str]"; expected "NoReturn" [arg-type]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
Mypy version used: mypy 1.2.0 (compiled: yes)
Mypy command-line flags: --show-error-codes
Mypy configuration options from mypy.ini (and other config files): n/a
In the first method, it seems to be case self.a / case self.b that Mypy is choking on, not match self. Because it works when changing them to case MyEnum.a / case MyEnum.b
Activity
frou commentedon Jul 18, 2023
In the first method, it seems to be
case self.a/case self.bthat Mypy is choking on, notmatch self. Because it works when changing them tocase MyEnum.a/case MyEnum.bfrou commentedon Jul 18, 2023
Possibly related issue: #12107
MestreLion commentedon Aug 3, 2023
Most likely a duplicate of #10910
Support attribute access on enum members correctly (python#19422)