Open
Description
Bug Report
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.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=6f0acfbf4f32fd48e7d6284b15368919
Actual Behavior
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 - Python version used: Python 3.11.1