-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add NoReturn #811
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
Add NoReturn #811
Conversation
It looks like right now there's no good way to alias |
This is rather because of mypy_extensions.py in Mypy master not containing NoReturn yet. Mypy doesn't even look at the stub. Land python/mypy#2637 and it should work. |
It's actually the other way round: if there's a stub, mypy doesn't look at the corresponding I worked around the aliasing issue here by using |
Right, I thought there's something special going on about mypy_extensions, just like lib-typing over typing.pyi. |
# Return type that indicates a function does not return. | ||
# This type is equivalent to the None type, but the no-op Union is necessary to | ||
# distinguish the None type from the None value. | ||
NoReturn = Union[None] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand this. NoReturn
is different from the NoneType
, the latter is a type with one value, while the former is a type with no values, a.k.a. "error type" or "bottom type". Maybe it would be better to write class NoReturn: ...
?
@gvanrossum What do you think about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent is to not disrupt typecheckers that don't yet support this (as it's not yet part of PEP 484).
Adds
mypy_extensions.NoReturn
as an alias for None and changes the annotation of some standard functions which don't return. Mypy will soon understand that this indicates a function cannot return (which is important for the--warn-no-return
flag, which we're considering enabling by default).