Make signature of DictMixin.get consistent with Mapping.get (#838)

This commit is contained in:
Jukka Lehtosalo
2017-01-17 14:08:49 +00:00
committed by GitHub
parent 734ad44a11
commit 35978a7ca5

View File

@@ -1,8 +1,9 @@
from typing import (Any, Container, Dict, Generic, Iterable, Iterator, List,
Mapping, Sized, Tuple, TypeVar, overload)
Mapping, Optional, Sized, Tuple, TypeVar, Union, overload)
_KT = TypeVar('_KT')
_VT = TypeVar('_VT')
_T = TypeVar('_T')
class UserDict(Dict[_KT, _VT], Generic[_KT, _VT]):
data = ... # type: Mapping[_KT, _VT]
@@ -19,7 +20,10 @@ class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]):
# From typing.Mapping[_KT, _VT]
# (can't inherit because of keys())
def get(self, k: _KT, default: _VT = ...) -> _VT: ...
@overload
def get(self, k: _KT) -> Optional[_VT]: ...
@overload
def get(self, k: _KT, default: _T) -> Union[_VT, _T]: ...
def values(self) -> List[_VT]: ...
def items(self) -> List[Tuple[_KT, _VT]]: ...
def iterkeys(self) -> Iterator[_KT]: ...