mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-26 13:51:30 +08:00
Normalise use of Never vs NoReturn (#8549)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import sys
|
||||
import threading
|
||||
from typing import NoReturn
|
||||
from typing_extensions import Never
|
||||
|
||||
_global_lock: threading.Lock
|
||||
|
||||
class _LoopBoundMixin:
|
||||
if sys.version_info < (3, 11):
|
||||
def __init__(self, *, loop: NoReturn = ...) -> None: ...
|
||||
def __init__(self, *, loop: Never = ...) -> None: ...
|
||||
|
||||
@@ -18,7 +18,7 @@ from types import (
|
||||
TracebackType,
|
||||
WrapperDescriptorType,
|
||||
)
|
||||
from typing_extensions import ParamSpec as _ParamSpec, final as _final
|
||||
from typing_extensions import Never as _Never, ParamSpec as _ParamSpec, final as _final
|
||||
|
||||
__all__ = [
|
||||
"AbstractSet",
|
||||
@@ -791,13 +791,13 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
|
||||
__required_keys__: ClassVar[frozenset[str]]
|
||||
__optional_keys__: ClassVar[frozenset[str]]
|
||||
def copy(self: _typeshed.Self) -> _typeshed.Self: ...
|
||||
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
|
||||
# Using Never so that only calls using mypy plugin hook that specialize the signature
|
||||
# can go through.
|
||||
def setdefault(self, k: NoReturn, default: object) -> object: ...
|
||||
def setdefault(self, k: _Never, default: object) -> object: ...
|
||||
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
|
||||
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
|
||||
def pop(self, k: _Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
|
||||
def update(self: _T, __m: _T) -> None: ...
|
||||
def __delitem__(self, k: NoReturn) -> None: ...
|
||||
def __delitem__(self, k: _Never) -> None: ...
|
||||
def items(self) -> dict_items[str, object]: ...
|
||||
def keys(self) -> dict_keys[str, object]: ...
|
||||
def values(self) -> dict_values[str, object]: ...
|
||||
|
||||
@@ -127,16 +127,16 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
|
||||
__optional_keys__: ClassVar[frozenset[str]]
|
||||
__total__: ClassVar[bool]
|
||||
def copy(self: _typeshed.Self) -> _typeshed.Self: ...
|
||||
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
|
||||
# Using Never so that only calls using mypy plugin hook that specialize the signature
|
||||
# can go through.
|
||||
def setdefault(self, k: NoReturn, default: object) -> object: ...
|
||||
def setdefault(self, k: Never, default: object) -> object: ...
|
||||
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
|
||||
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
|
||||
def pop(self, k: Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
|
||||
def update(self: _T, __m: _T) -> None: ...
|
||||
def items(self) -> dict_items[str, object]: ...
|
||||
def keys(self) -> dict_keys[str, object]: ...
|
||||
def values(self) -> dict_values[str, object]: ...
|
||||
def __delitem__(self, k: NoReturn) -> None: ...
|
||||
def __delitem__(self, k: Never) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __or__(self: _typeshed.Self, __value: _typeshed.Self) -> _typeshed.Self: ...
|
||||
def __ior__(self: _typeshed.Self, __value: _typeshed.Self) -> _typeshed.Self: ...
|
||||
@@ -221,9 +221,9 @@ if sys.version_info >= (3, 11):
|
||||
)
|
||||
else:
|
||||
Self: _SpecialForm
|
||||
Never: _SpecialForm
|
||||
Never: _SpecialForm = ...
|
||||
def reveal_type(__obj: _T) -> _T: ...
|
||||
def assert_never(__arg: NoReturn) -> NoReturn: ...
|
||||
def assert_never(__arg: Never) -> Never: ...
|
||||
def assert_type(__val: _T, __typ: Any) -> _T: ...
|
||||
def clear_overloads() -> None: ...
|
||||
def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ...
|
||||
|
||||
@@ -4,6 +4,7 @@ from _collections_abc import dict_items, dict_keys, dict_values
|
||||
from _typeshed import IdentityFunction, Self
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, ClassVar, Generic, TypeVar, overload, type_check_only
|
||||
from typing_extensions import Never
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_U = TypeVar("_U")
|
||||
@@ -16,16 +17,16 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
|
||||
# Unlike typing(_extensions).TypedDict,
|
||||
# subclasses of mypy_extensions.TypedDict do NOT have the __required_keys__ and __optional_keys__ ClassVars
|
||||
def copy(self: Self) -> Self: ...
|
||||
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
|
||||
# Using Never so that only calls using mypy plugin hook that specialize the signature
|
||||
# can go through.
|
||||
def setdefault(self, k: NoReturn, default: object) -> object: ...
|
||||
def setdefault(self, k: Never, default: object) -> object: ...
|
||||
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
|
||||
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
|
||||
def pop(self, k: Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
|
||||
def update(self: Self, __m: Self) -> None: ...
|
||||
def items(self) -> dict_items[str, object]: ...
|
||||
def keys(self) -> dict_keys[str, object]: ...
|
||||
def values(self) -> dict_values[str, object]: ...
|
||||
def __delitem__(self, k: NoReturn) -> None: ...
|
||||
def __delitem__(self, k: Never) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __or__(self: Self, __other: Self) -> Self: ...
|
||||
def __ior__(self: Self, __other: Self) -> Self: ...
|
||||
|
||||
Reference in New Issue
Block a user