Return ItemsView/KeysView from Mapping methods (#6014)

* Return ItemsView/KeysView from Mapping methods

* Make RawConfigParser compatible with Mapping
This commit is contained in:
Sebastian Rittau
2021-09-09 16:37:26 +02:00
committed by GitHub
parent b9e1d7d522
commit 2f3964e24b
2 changed files with 7 additions and 23 deletions

View File

@@ -435,7 +435,7 @@ class AsyncContextManager(Protocol[_T_co]):
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.
# see discussion in https://github.com/python/typing/pull/273.
@abstractmethod
def __getitem__(self, k: _KT) -> _VT_co: ...
# Mixin methods
@@ -443,8 +443,8 @@ class Mapping(_Collection[_KT], Generic[_KT, _VT_co]):
def get(self, key: _KT) -> _VT_co | None: ...
@overload
def get(self, key: _KT, default: _VT_co | _T) -> _VT_co | _T: ...
def items(self) -> AbstractSet[Tuple[_KT, _VT_co]]: ...
def keys(self) -> AbstractSet[_KT]: ...
def items(self) -> ItemsView[_KT, _VT_co]: ...
def keys(self) -> KeysView[_KT]: ...
def values(self) -> ValuesView[_VT_co]: ...
def __contains__(self, o: object) -> bool: ...