-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(🎁) Support typing.assert_never
(and the one from typing_extensions
)
#12399
Labels
Comments
Your example gives two straightforward errors ( This fixed version behaves as expected: from typing import NoReturn as Never
def assert_never(__arg: Never) -> Never:
"""Custom impl for demonstration purposes only. (mypy doesn't have stubs for the real one)"""
...
def f(x: bool):
assert_never(x) # error
if x is True:
pass
elif x is False:
pass
else:
assert_never(x) # no error Can you clarify what you think is wrong?
|
😳True, sorry about that. |
@JelleZijlstra Why does |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mypy should report an error when
assert_never
is used in a position that is reachable.Related: #12253
The text was updated successfully, but these errors were encountered: