stdlib mapping classes: Use better names for various pos-only parameters (#8637)

This commit is contained in:
Nikita Sobolev
2022-08-29 01:29:00 +03:00
committed by GitHub
parent 1b6cda86d4
commit 6e985ef3de
5 changed files with 14 additions and 14 deletions

View File

@@ -115,16 +115,16 @@ class SupportsItems(Protocol[_KT_co, _VT_co]):
# stable
class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
def keys(self) -> Iterable[_KT]: ...
def __getitem__(self, __k: _KT) -> _VT_co: ...
def __getitem__(self, __key: _KT) -> _VT_co: ...
# stable
class SupportsGetItem(Container[_KT_contra], Protocol[_KT_contra, _VT_co]):
def __getitem__(self, __k: _KT_contra) -> _VT_co: ...
def __getitem__(self, __key: _KT_contra) -> _VT_co: ...
# stable
class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, _VT]):
def __setitem__(self, __k: _KT_contra, __v: _VT) -> None: ...
def __delitem__(self, __v: _KT_contra) -> None: ...
def __setitem__(self, __key: _KT_contra, __value: _VT) -> None: ...
def __delitem__(self, __key: _KT_contra) -> None: ...
StrPath: TypeAlias = str | PathLike[str] # stable
BytesPath: TypeAlias = bytes | PathLike[bytes] # stable

View File

@@ -1059,9 +1059,9 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
@overload
def pop(self, __key: _KT, __default: _VT | _T) -> _VT | _T: ...
def __len__(self) -> int: ...
def __getitem__(self, __k: _KT) -> _VT: ...
def __setitem__(self, __k: _KT, __v: _VT) -> None: ...
def __delitem__(self, __v: _KT) -> None: ...
def __getitem__(self, __key: _KT) -> _VT: ...
def __setitem__(self, __key: _KT, __value: _VT) -> None: ...
def __delitem__(self, __key: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[_KT]: ...

View File

@@ -68,9 +68,9 @@ class ValueProxy(BaseProxy, Generic[_T]):
class DictProxy(BaseProxy, MutableMapping[_KT, _VT]):
__builtins__: ClassVar[dict[str, Any]]
def __len__(self) -> int: ...
def __getitem__(self, __k: _KT) -> _VT: ...
def __setitem__(self, __k: _KT, __v: _VT) -> None: ...
def __delitem__(self, __v: _KT) -> None: ...
def __getitem__(self, __key: _KT) -> _VT: ...
def __setitem__(self, __key: _KT, __value: _VT) -> None: ...
def __delitem__(self, __key: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
def copy(self) -> dict[_KT, _VT]: ...
@overload

View File

@@ -304,7 +304,7 @@ class CodeType:
class MappingProxyType(Mapping[_KT, _VT_co], Generic[_KT, _VT_co]):
__hash__: ClassVar[None] # type: ignore[assignment]
def __init__(self, mapping: SupportsKeysAndGetItem[_KT, _VT_co]) -> None: ...
def __getitem__(self, __k: _KT) -> _VT_co: ...
def __getitem__(self, __key: _KT) -> _VT_co: ...
def __iter__(self) -> Iterator[_KT]: ...
def __len__(self) -> int: ...
def copy(self) -> dict[_KT, _VT_co]: ...

View File

@@ -576,7 +576,7 @@ class Mapping(Collection[_KT], Generic[_KT, _VT_co]):
# TODO: We wish the key type could also be covariant, but that doesn't work,
# see discussion in https://github.com/python/typing/pull/273.
@abstractmethod
def __getitem__(self, __k: _KT) -> _VT_co: ...
def __getitem__(self, __key: _KT) -> _VT_co: ...
# Mixin methods
@overload
def get(self, __key: _KT) -> _VT_co | None: ...
@@ -589,9 +589,9 @@ class Mapping(Collection[_KT], Generic[_KT, _VT_co]):
class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]):
@abstractmethod
def __setitem__(self, __k: _KT, __v: _VT) -> None: ...
def __setitem__(self, __key: _KT, __value: _VT) -> None: ...
@abstractmethod
def __delitem__(self, __v: _KT) -> None: ...
def __delitem__(self, __key: _KT) -> None: ...
def clear(self) -> None: ...
@overload
def pop(self, __key: _KT) -> _VT: ...