Normalise use of Never vs NoReturn (#8549)

This commit is contained in:
Alex Waygood
2022-08-17 22:53:40 +02:00
committed by GitHub
parent 0b28177268
commit 2c052651e9
4 changed files with 18 additions and 17 deletions

View File

@@ -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: ...