From a7adb870e9cb4342fbeb5ed968b1b7ca97391c40 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Thu, 7 Jan 2021 01:10:02 -0800 Subject: [PATCH] builtins: add an overload for getattr with None default This found a couple issues in mypy (see https://github.com/python/mypy/pull/9889) --- stdlib/3/builtins.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index db7e8e2bf1af..7321ca60a2ba 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -966,6 +966,9 @@ def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> Iterator[_T] @overload def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> Iterator[_T]: ... def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode +@overload +def getattr(__o: Any, name: str, __default: None) -> Optional[Any]: ... +@overload def getattr(__o: Any, name: str, __default: Any = ...) -> Any: ... def globals() -> Dict[str, Any]: ... def hasattr(__obj: Any, __name: str) -> bool: ...