change getattr stubs to better type the default argument and return type (#5516)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
Neil Vyas
2021-05-21 18:44:11 -05:00
committed by GitHub
parent dbaaa3a103
commit 8d56328a24
3 changed files with 18 additions and 3 deletions

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -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: ...