add ChainMap class to collections module (#361)

* add ChainMap class to collections module

* ...and add it for Python 2 as well.
This commit is contained in:
speezepearson
2016-07-13 06:16:37 -07:00
committed by Matthias Kramm
parent e436795124
commit e815c803a6
2 changed files with 28 additions and 0 deletions

View File

@@ -90,3 +90,17 @@ 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

@@ -133,3 +133,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: ...
@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]: ...