Use _typeshed.Self in Python 2, too (#6932)

This commit is contained in:
Alex Waygood
2022-01-16 22:44:51 +00:00
committed by GitHub
parent 0949e9e90d
commit 6a88d5e7ae
29 changed files with 156 additions and 160 deletions

View File

@@ -1,4 +1,5 @@
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
from _typeshed import Self
from abc import ABCMeta, abstractmethod
from types import CodeType, FrameType, TracebackType
@@ -462,11 +463,11 @@ class NamedTuple(Tuple[Any, ...]):
@classmethod
def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ...
def _asdict(self) -> Dict[str, Any]: ...
def _replace(self: _T, **kwargs: Any) -> _T: ...
def _replace(self: Self, **kwargs: Any) -> Self: ...
# Internal mypy fallback type for all typed dicts (does not exist at runtime)
class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
def copy(self: _T) -> _T: ...
def copy(self: Self) -> Self: ...
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
# can go through.
def setdefault(self, k: NoReturn, default: object) -> object: ...