diff --git a/stdlib/@python2/__builtin__.pyi b/stdlib/@python2/__builtin__.pyi index 4eb5424d8..b7b68bbb7 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -861,7 +861,12 @@ def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: .. @overload def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode -def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ... +@overload +def getattr(__o: Any, name: Text) -> Any: ... +@overload +def getattr(__o: Any, name: Text, __default: None) -> Optional[Any]: ... +@overload +def getattr(__o: Any, name: Text, __default: _T) -> Union[Any, _T]: ... def globals() -> Dict[str, Any]: ... def hasattr(__obj: Any, __name: Text) -> bool: ... def hash(__obj: object) -> int: ... diff --git a/stdlib/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index 4eb5424d8..b7b68bbb7 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -861,7 +861,12 @@ def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: .. @overload def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode -def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ... +@overload +def getattr(__o: Any, name: Text) -> Any: ... +@overload +def getattr(__o: Any, name: Text, __default: None) -> Optional[Any]: ... +@overload +def getattr(__o: Any, name: Text, __default: _T) -> Union[Any, _T]: ... def globals() -> Dict[str, Any]: ... def hasattr(__obj: Any, __name: Text) -> bool: ... def hash(__obj: object) -> int: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 1710de35d..865c6e9a1 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1019,7 +1019,12 @@ class filter(Iterator[_T], Generic[_T]): def __next__(self) -> _T: ... def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode -def getattr(__o: Any, name: str, __default: Any = ...) -> Any: ... +@overload +def getattr(__o: Any, name: str) -> Any: ... +@overload +def getattr(__o: Any, name: str, __default: None) -> Optional[Any]: ... +@overload +def getattr(__o: Any, name: str, __default: _T) -> Union[Any, _T]: ... def globals() -> Dict[str, Any]: ... def hasattr(__obj: Any, __name: str) -> bool: ... def hash(__obj: object) -> int: ...