Use typing_extensions.Self in the stdlib (#9694)

This commit is contained in:
Alex Waygood
2023-02-09 09:12:13 +00:00
committed by GitHub
parent 10086c06a1
commit 9ed39d8796
98 changed files with 627 additions and 654 deletions

View File

@@ -1,4 +1,3 @@
import _typeshed
import abc
import collections
import sys
@@ -129,7 +128,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
__required_keys__: ClassVar[frozenset[str]]
__optional_keys__: ClassVar[frozenset[str]]
__total__: ClassVar[bool]
def copy(self: _typeshed.Self) -> _typeshed.Self: ...
def copy(self) -> Self: ...
# Using Never so that only calls using mypy plugin hook that specialize the signature
# can go through.
def setdefault(self, k: Never, default: object) -> object: ...
@@ -141,8 +140,8 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
def values(self) -> dict_values[str, object]: ...
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: ...
def __or__(self, __value: Self) -> Self: ...
def __ior__(self, __value: Self) -> Self: ...
# TypedDict is a (non-subscriptable) special form.
TypedDict: object
@@ -244,13 +243,13 @@ else:
@overload
def __init__(self, typename: str, fields: None = None, **kwargs: Any) -> None: ...
@classmethod
def _make(cls: type[_typeshed.Self], iterable: Iterable[Any]) -> _typeshed.Self: ...
def _make(cls, iterable: Iterable[Any]) -> Self: ...
if sys.version_info >= (3, 8):
def _asdict(self) -> dict[str, Any]: ...
else:
def _asdict(self) -> collections.OrderedDict[str, Any]: ...
def _replace(self: _typeshed.Self, **kwargs: Any) -> _typeshed.Self: ...
def _replace(self, **kwargs: Any) -> Self: ...
# New things in 3.xx
# The `default` parameter was added to TypeVar, ParamSpec, and TypeVarTuple (PEP 696)