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
Spec: Allow NoReturn
to appear outside of function return type annotations
#1558
Comments
Should we also clearly state that |
I don't have a strong opinion one way or another about this, but I think that's a separate issue. |
It is related in my mind, since |
The docs don't actually state that If you just want to use it as a return type to say that a function never returns (because it enters into an infinite loop or whatever), then the name |
I would propose that the spec should state that Never and NoReturn should be treated as exact equivalents by type checkers. There are reasons to use one name over the other, but that's more of a style guide issue, not a spec issue. |
Thanks @AlexWaygood and @JelleZijlstra! I agree that it makes sense to treat |
The typing spec currently states:
This is old language from the time when
NoReturn
was first added in PEP 484. Since then, we've addedNever
to the typing spec and indicated thatNever
andNoReturn
are equivalent types. Even beforeNever
was added, theassert_never
function made use ofNoReturn
outside of a return annotation.No type checker currently enforces that
NoReturn
appears only in return type annotations of functions. I'd like to propose that we simply delete that section of the spec. That would bring the spec into alignment with the current behavior of all four major type checkers.The text was updated successfully, but these errors were encountered: