mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-25 11:07:17 +08:00
stdlib: Add several missing __(deep)copy__ methods (#7242)
This commit is contained in:
@@ -57,6 +57,9 @@ class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __iter__(self) -> Iterator[_KT]: ...
|
||||
def __contains__(self, key: object) -> bool: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def __copy__(self: Self) -> Self: ...
|
||||
|
||||
# `UserDict.fromkeys` has the same semantics as `dict.fromkeys`, so should be kept in line with `dict.fromkeys`.
|
||||
# TODO: Much like `dict.fromkeys`, the true signature of `UserDict.fromkeys` is inexpressible in the current type system.
|
||||
# See #3800 & https://github.com/python/typing/issues/548#issuecomment-683336963.
|
||||
@@ -105,6 +108,9 @@ class UserList(MutableSequence[_T]):
|
||||
def pop(self, i: int = ...) -> _T: ...
|
||||
def remove(self, item: _T) -> None: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def __copy__(self: Self) -> Self: ...
|
||||
|
||||
def count(self, item: _T) -> int: ...
|
||||
# All arguments are passed to `list.index` at runtime, so the signature should be kept in line with `list.index`.
|
||||
def index(self, item: _T, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ...
|
||||
@@ -375,6 +381,7 @@ class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
@overload
|
||||
def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
__copy__ = copy
|
||||
# All arguments to `fromkeys` are passed to `dict.fromkeys` at runtime, so the signature should be kept in line with `dict.fromkeys`.
|
||||
@classmethod
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user