Skip to content

Commit 9eabedc

Browse files
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.
1 parent 3324e22 commit 9eabedc

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
9090
fail-fast: false
9191
env:
92-
PYRIGHT_VERSION: 1.1.184 # Must match pyright_test.py.
92+
PYRIGHT_VERSION: 1.1.187 # Must match pyright_test.py.
9393
steps:
9494
- uses: actions/checkout@v2
9595
- uses: jakebailey/pyright-action@v1

stdlib/typing.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Protocol: _SpecialForm = ...
5050
Callable: _SpecialForm = ...
5151
Type: _SpecialForm = ...
5252
ClassVar: _SpecialForm = ...
53+
NoReturn: _SpecialForm = ...
5354
if sys.version_info >= (3, 8):
5455
Final: _SpecialForm = ...
5556
def final(f: _T) -> _T: ...
@@ -83,11 +84,6 @@ if sys.version_info >= (3, 10):
8384
TypeAlias: _SpecialForm = ...
8485
TypeGuard: _SpecialForm = ...
8586

86-
# Return type that indicates a function does not return.
87-
# This type is equivalent to the None type, but the no-op Union is necessary to
88-
# distinguish the None type from the None value.
89-
NoReturn = Union[None]
90-
9187
# These type variables are used by the container types.
9288
_S = TypeVar("_S")
9389
_KT = TypeVar("_KT") # Key type.

tests/pyright_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66
from pathlib import Path
77

8-
_PYRIGHT_VERSION = "1.1.184" # Must match tests.yml.
8+
_PYRIGHT_VERSION = "1.1.187" # Must match tests.yml.
99
_WELL_KNOWN_FILE = Path("tests", "pyright_test.py")
1010

1111

0 commit comments

Comments
 (0)