ChainMap fixes (#878)

- It didn't exist before 3.3 (https://docs.python.org/3/library/collections.html#chainmap-objects)
- It's not a subclass of dict
This commit is contained in:
Jelle Zijlstra
2017-01-29 20:29:29 -08:00
committed by Guido van Rossum
parent bb5ba13315
commit 6e84021f56
2 changed files with 11 additions and 24 deletions

View File

@@ -92,17 +92,3 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
def __init__(self, default_factory: Callable[[], _VT],
iterable: Iterable[Tuple[_KT, _VT]]) -> None: ...
def __missing__(self, key: _KT) -> _VT: ...
class ChainMap(Dict[_KT, _VT], Generic[_KT, _VT]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...
@property
def maps(self) -> List[Mapping[_KT, _VT]]: ...
def new_child(self, m: Mapping[_KT, _VT] = ...) -> ChainMap[_KT, _VT]: ...
@property
def parents(self) -> ChainMap[_KT, _VT]: ...

View File

@@ -166,16 +166,17 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
def __missing__(self, key: _KT) -> _VT: ...
# TODO __reversed__
class ChainMap(Dict[_KT, _VT], Generic[_KT, _VT]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...
if sys.version_info >= (3, 3):
class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...
@property
def maps(self) -> List[Mapping[_KT, _VT]]: ...
@property
def maps(self) -> List[Mapping[_KT, _VT]]: ...
def new_child(self, m: Mapping[_KT, _VT] = ...) -> ChainMap[_KT, _VT]: ...
def new_child(self, m: Mapping[_KT, _VT] = ...) -> ChainMap[_KT, _VT]: ...
@property
def parents(self) -> ChainMap[_KT, _VT]: ...
@property
def parents(self) -> ChainMap[_KT, _VT]: ...