mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Use typing_extensions.Self in the stdlib (#9694)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import _typeshed
|
||||
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
|
||||
import sys
|
||||
import typing_extensions
|
||||
@@ -502,7 +501,7 @@ class MutableSequence(Sequence[_T], Generic[_T]):
|
||||
def reverse(self) -> None: ...
|
||||
def pop(self, index: int = -1) -> _T: ...
|
||||
def remove(self, value: _T) -> None: ...
|
||||
def __iadd__(self: _typeshed.Self, values: Iterable[_T]) -> _typeshed.Self: ...
|
||||
def __iadd__(self, values: Iterable[_T]) -> typing_extensions.Self: ...
|
||||
|
||||
class AbstractSet(Collection[_T_co], Generic[_T_co]):
|
||||
@abstractmethod
|
||||
@@ -528,10 +527,10 @@ class MutableSet(AbstractSet[_T], Generic[_T]):
|
||||
def clear(self) -> None: ...
|
||||
def pop(self) -> _T: ...
|
||||
def remove(self, value: _T) -> None: ...
|
||||
def __ior__(self: _typeshed.Self, it: AbstractSet[_T]) -> _typeshed.Self: ... # type: ignore[override,misc]
|
||||
def __iand__(self: _typeshed.Self, it: AbstractSet[Any]) -> _typeshed.Self: ...
|
||||
def __ixor__(self: _typeshed.Self, it: AbstractSet[_T]) -> _typeshed.Self: ... # type: ignore[override,misc]
|
||||
def __isub__(self: _typeshed.Self, it: AbstractSet[Any]) -> _typeshed.Self: ...
|
||||
def __ior__(self, it: AbstractSet[_T]) -> typing_extensions.Self: ... # type: ignore[override,misc]
|
||||
def __iand__(self, it: AbstractSet[Any]) -> typing_extensions.Self: ...
|
||||
def __ixor__(self, it: AbstractSet[_T]) -> typing_extensions.Self: ... # type: ignore[override,misc]
|
||||
def __isub__(self, it: AbstractSet[Any]) -> typing_extensions.Self: ...
|
||||
|
||||
class MappingView(Sized):
|
||||
def __init__(self, mapping: Mapping[Any, Any]) -> None: ... # undocumented
|
||||
@@ -792,7 +791,7 @@ class NamedTuple(tuple[Any, ...]):
|
||||
else:
|
||||
def _asdict(self) -> collections.OrderedDict[str, Any]: ...
|
||||
|
||||
def _replace(self: _typeshed.Self, **kwargs: Any) -> _typeshed.Self: ...
|
||||
def _replace(self, **kwargs: Any) -> typing_extensions.Self: ...
|
||||
|
||||
# Internal mypy fallback type for all typed dicts (does not exist at runtime)
|
||||
# N.B. Keep this mostly in sync with typing_extensions._TypedDict/mypy_extensions._TypedDict
|
||||
@@ -802,7 +801,7 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
|
||||
if sys.version_info >= (3, 9):
|
||||
__required_keys__: ClassVar[frozenset[str]]
|
||||
__optional_keys__: ClassVar[frozenset[str]]
|
||||
def copy(self: _typeshed.Self) -> _typeshed.Self: ...
|
||||
def copy(self) -> typing_extensions.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: ...
|
||||
@@ -814,8 +813,8 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
|
||||
def keys(self) -> dict_keys[str, object]: ...
|
||||
def values(self) -> dict_values[str, object]: ...
|
||||
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: typing_extensions.Self) -> typing_extensions.Self: ...
|
||||
def __ior__(self, __value: typing_extensions.Self) -> typing_extensions.Self: ...
|
||||
|
||||
@_final
|
||||
class ForwardRef:
|
||||
|
||||
Reference in New Issue
Block a user