From bcf68e1499bee23d64c5547382224555c8b750e0 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 12 Nov 2021 15:23:30 -0800 Subject: [PATCH 1/2] Make NoReturn a SpecialForm 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. --- stdlib/typing.pyi | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index a7986b10aeb8..148ac021c55d 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -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. From 4fe22d213e07f1fd1e19a140d751972025cc5bc4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 12 Nov 2021 17:10:54 -0800 Subject: [PATCH 2/2] update pyright version --- .github/workflows/tests.yml | 2 +- tests/pyright_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 64e9e4aef77a..904c2a205771 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/tests/pyright_test.py b/tests/pyright_test.py index 4505a8440bc6..312b4d4a8d8c 100755 --- a/tests/pyright_test.py +++ b/tests/pyright_test.py @@ -5,7 +5,7 @@ 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")