Repository navigation
Make NoReturn a SpecialForm - #6290
Merged
Merged
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.
Member
Author
|
Thanks! |
This comment has been minimized.
This comment has been minimized.
Contributor
|
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. |
Contributor
|
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. |
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Member
Author
|
Thanks for the very quick fix! CI passes now. |
srittau
approved these changes
Nov 13, 2021
Contributor
|
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.