Make NoReturn a SpecialForm (#6290)

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.
This commit is contained in:
Jelle Zijlstra
2021-11-12 17:34:44 -08:00
committed by GitHub
parent 3324e2277e
commit 9eabedca5f
3 changed files with 3 additions and 7 deletions

View File

@@ -89,7 +89,7 @@ jobs:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
fail-fast: false
env:
PYRIGHT_VERSION: 1.1.184 # Must match pyright_test.py.
PYRIGHT_VERSION: 1.1.187 # Must match pyright_test.py.
steps:
- uses: actions/checkout@v2
- uses: jakebailey/pyright-action@v1

View File

@@ -50,6 +50,7 @@ Protocol: _SpecialForm = ...
Callable: _SpecialForm = ...
Type: _SpecialForm = ...
ClassVar: _SpecialForm = ...
NoReturn: _SpecialForm = ...
if sys.version_info >= (3, 8):
Final: _SpecialForm = ...
def final(f: _T) -> _T: ...
@@ -83,11 +84,6 @@ if sys.version_info >= (3, 10):
TypeAlias: _SpecialForm = ...
TypeGuard: _SpecialForm = ...
# 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]
# These type variables are used by the container types.
_S = TypeVar("_S")
_KT = TypeVar("_KT") # Key type.

View File

@@ -5,7 +5,7 @@ import subprocess
import sys
from pathlib import Path
_PYRIGHT_VERSION = "1.1.184" # Must match tests.yml.
_PYRIGHT_VERSION = "1.1.187" # Must match tests.yml.
_WELL_KNOWN_FILE = Path("tests", "pyright_test.py")