-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Make NoReturn a SpecialForm #6290
Conversation
This is consistent with the runtime definition: https://github.com/python/cpython/blob/main/Lib/typing.py#L434. The previous definition was wrong; NoReturn is not and should not be equivalent to None. This fixes an issue in pyanalyze where it was interpreting NoReturn as equivalent to None. cc @erictraut in case this affects pyright. mypy-primer will tell us what mypy thinks about it.
Thanks! |
This comment has been minimized.
This comment has been minimized.
I've made the necessary changes in pyright, and I'll be publishing a new version within the next few hours. We can then update your PR to point to the new version, which should eliminate the CI errors. |
I've published pyright 1.1.187, which fixes this issue. Typeshed currently uses 1.1.184. If you update this version (in both workflows/tests.yml and tests/pyright_test.py) within your PR, the CI errors should disappear. |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Thanks for the very quick fix! CI passes now. |
I think the original author's intent would be much more accurately described with: NoReturn: TypeAlias = Union[()] # "<nothing>" 😳😳😳😳😳😳😳😳😳😳😳😳This works correctly at type time: from typing import TypeAlias, Union
Never: TypeAlias = Union[()]
a: Never = 1 # error: Incompatible types in assignment (expression has type "int", variable has type <nothing>) But not at runtime 😁. Good thing it's just a stub. |
This is consistent with the runtime definition: https://github.com/python/cpython/blob/main/Lib/typing.py#L434.
The previous definition was wrong; NoReturn is not and should not be equivalent to None. This fixes an issue in pyanalyze where it was interpreting NoReturn as equivalent to None.
cc @erictraut in case this affects pyright. mypy-primer will tell us what mypy thinks about it.