diff --git a/stdlib/@python2/__builtin__.pyi b/stdlib/@python2/__builtin__.pyi index 95252ef2dd66..fad8b2b4e7d8 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -850,13 +850,18 @@ def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicod @overload def getattr(__o: Any, name: Text) -> Any: ... -# While technically covered by the last overload, spelling out the types for None and bool -# help mypy out in some tricky situations involving type context (aka bidirectional inference) +# While technically covered by the last overload, spelling out the types for None, bool +# and basic containers help mypy out in some tricky situations involving type context +# (aka bidirectional inference) @overload def getattr(__o: Any, name: Text, __default: None) -> Any | None: ... @overload def getattr(__o: Any, name: Text, __default: bool) -> Any | bool: ... @overload +def getattr(__o: object, name: str, __default: list[Any]) -> Any | list[Any]: ... +@overload +def getattr(__o: object, name: str, __default: dict[Any, Any]) -> Any | dict[Any, Any]: ... +@overload def getattr(__o: Any, name: Text, __default: _T) -> Any | _T: ... def globals() -> Dict[str, Any]: ... def hasattr(__obj: Any, __name: Text) -> bool: ... diff --git a/stdlib/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index 95252ef2dd66..fad8b2b4e7d8 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -850,13 +850,18 @@ def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicod @overload def getattr(__o: Any, name: Text) -> Any: ... -# While technically covered by the last overload, spelling out the types for None and bool -# help mypy out in some tricky situations involving type context (aka bidirectional inference) +# While technically covered by the last overload, spelling out the types for None, bool +# and basic containers help mypy out in some tricky situations involving type context +# (aka bidirectional inference) @overload def getattr(__o: Any, name: Text, __default: None) -> Any | None: ... @overload def getattr(__o: Any, name: Text, __default: bool) -> Any | bool: ... @overload +def getattr(__o: object, name: str, __default: list[Any]) -> Any | list[Any]: ... +@overload +def getattr(__o: object, name: str, __default: dict[Any, Any]) -> Any | dict[Any, Any]: ... +@overload def getattr(__o: Any, name: Text, __default: _T) -> Any | _T: ... def globals() -> Dict[str, Any]: ... def hasattr(__obj: Any, __name: Text) -> bool: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 388ce3380447..dfafe6f738e5 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1057,13 +1057,18 @@ def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicod @overload def getattr(__o: object, __name: str) -> Any: ... -# While technically covered by the last overload, spelling out the types for None and bool -# help mypy out in some tricky situations involving type context (aka bidirectional inference) +# While technically covered by the last overload, spelling out the types for None, bool +# and basic containers help mypy out in some tricky situations involving type context +# (aka bidirectional inference) @overload def getattr(__o: object, __name: str, __default: None) -> Any | None: ... @overload def getattr(__o: object, __name: str, __default: bool) -> Any | bool: ... @overload +def getattr(__o: object, name: str, __default: list[Any]) -> Any | list[Any]: ... +@overload +def getattr(__o: object, name: str, __default: dict[Any, Any]) -> Any | dict[Any, Any]: ... +@overload def getattr(__o: object, __name: str, __default: _T) -> Any | _T: ... def globals() -> dict[str, Any]: ... def hasattr(__obj: object, __name: str) -> bool: ...