From 35978a7ca500eabe9136e1cf28ec4c281781d806 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Tue, 17 Jan 2017 14:08:49 +0000 Subject: [PATCH] Make signature of DictMixin.get consistent with Mapping.get (#838) --- stdlib/2/UserDict.pyi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stdlib/2/UserDict.pyi b/stdlib/2/UserDict.pyi index 2d2b8c6c4..6b1f528f7 100644 --- a/stdlib/2/UserDict.pyi +++ b/stdlib/2/UserDict.pyi @@ -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]: ...