Skip to content

Commit 2c05265

Browse files
authored
Normalise use of Never vs NoReturn (#8549)
1 parent 0b28177 commit 2c05265

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

stdlib/asyncio/mixins.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import sys
22
import threading
3-
from typing import NoReturn
3+
from typing_extensions import Never
44

55
_global_lock: threading.Lock
66

77
class _LoopBoundMixin:
88
if sys.version_info < (3, 11):
9-
def __init__(self, *, loop: NoReturn = ...) -> None: ...
9+
def __init__(self, *, loop: Never = ...) -> None: ...

stdlib/typing.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ from types import (
1818
TracebackType,
1919
WrapperDescriptorType,
2020
)
21-
from typing_extensions import ParamSpec as _ParamSpec, final as _final
21+
from typing_extensions import Never as _Never, ParamSpec as _ParamSpec, final as _final
2222

2323
__all__ = [
2424
"AbstractSet",
@@ -791,13 +791,13 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
791791
__required_keys__: ClassVar[frozenset[str]]
792792
__optional_keys__: ClassVar[frozenset[str]]
793793
def copy(self: _typeshed.Self) -> _typeshed.Self: ...
794-
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
794+
# Using Never so that only calls using mypy plugin hook that specialize the signature
795795
# can go through.
796-
def setdefault(self, k: NoReturn, default: object) -> object: ...
796+
def setdefault(self, k: _Never, default: object) -> object: ...
797797
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
798-
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
798+
def pop(self, k: _Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
799799
def update(self: _T, __m: _T) -> None: ...
800-
def __delitem__(self, k: NoReturn) -> None: ...
800+
def __delitem__(self, k: _Never) -> None: ...
801801
def items(self) -> dict_items[str, object]: ...
802802
def keys(self) -> dict_keys[str, object]: ...
803803
def values(self) -> dict_values[str, object]: ...

stdlib/typing_extensions.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
127127
__optional_keys__: ClassVar[frozenset[str]]
128128
__total__: ClassVar[bool]
129129
def copy(self: _typeshed.Self) -> _typeshed.Self: ...
130-
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
130+
# Using Never so that only calls using mypy plugin hook that specialize the signature
131131
# can go through.
132-
def setdefault(self, k: NoReturn, default: object) -> object: ...
132+
def setdefault(self, k: Never, default: object) -> object: ...
133133
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
134-
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
134+
def pop(self, k: Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
135135
def update(self: _T, __m: _T) -> None: ...
136136
def items(self) -> dict_items[str, object]: ...
137137
def keys(self) -> dict_keys[str, object]: ...
138138
def values(self) -> dict_values[str, object]: ...
139-
def __delitem__(self, k: NoReturn) -> None: ...
139+
def __delitem__(self, k: Never) -> None: ...
140140
if sys.version_info >= (3, 9):
141141
def __or__(self: _typeshed.Self, __value: _typeshed.Self) -> _typeshed.Self: ...
142142
def __ior__(self: _typeshed.Self, __value: _typeshed.Self) -> _typeshed.Self: ...
@@ -221,9 +221,9 @@ if sys.version_info >= (3, 11):
221221
)
222222
else:
223223
Self: _SpecialForm
224-
Never: _SpecialForm
224+
Never: _SpecialForm = ...
225225
def reveal_type(__obj: _T) -> _T: ...
226-
def assert_never(__arg: NoReturn) -> NoReturn: ...
226+
def assert_never(__arg: Never) -> Never: ...
227227
def assert_type(__val: _T, __typ: Any) -> _T: ...
228228
def clear_overloads() -> None: ...
229229
def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ...

stubs/mypy-extensions/mypy_extensions.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from _collections_abc import dict_items, dict_keys, dict_values
44
from _typeshed import IdentityFunction, Self
55
from collections.abc import Mapping
66
from typing import Any, ClassVar, Generic, TypeVar, overload, type_check_only
7+
from typing_extensions import Never
78

89
_T = TypeVar("_T")
910
_U = TypeVar("_U")
@@ -16,16 +17,16 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
1617
# Unlike typing(_extensions).TypedDict,
1718
# subclasses of mypy_extensions.TypedDict do NOT have the __required_keys__ and __optional_keys__ ClassVars
1819
def copy(self: Self) -> Self: ...
19-
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
20+
# Using Never so that only calls using mypy plugin hook that specialize the signature
2021
# can go through.
21-
def setdefault(self, k: NoReturn, default: object) -> object: ...
22+
def setdefault(self, k: Never, default: object) -> object: ...
2223
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
23-
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
24+
def pop(self, k: Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
2425
def update(self: Self, __m: Self) -> None: ...
2526
def items(self) -> dict_items[str, object]: ...
2627
def keys(self) -> dict_keys[str, object]: ...
2728
def values(self) -> dict_values[str, object]: ...
28-
def __delitem__(self, k: NoReturn) -> None: ...
29+
def __delitem__(self, k: Never) -> None: ...
2930
if sys.version_info >= (3, 9):
3031
def __or__(self: Self, __other: Self) -> Self: ...
3132
def __ior__(self: Self, __other: Self) -> Self: ...

0 commit comments

Comments
 (0)