Allow callables in _SourceObjectType (Python 2) (#3338)

This is important because mypy doesn't generally think functions are compatible with `FunctionType`, so `inspect.getsource` on arbitrary functions is rejected by the current annotations.
This commit is contained in:
Florian Bruhin
2019-10-11 05:51:56 +02:00
committed by Jelle Zijlstra
parent d41bcd39e1
commit 9b0922166a

View File

@@ -52,7 +52,7 @@ def isgetsetdescriptor(object: object) -> bool: ...
def ismemberdescriptor(object: object) -> bool: ...
# Retrieving source code
_SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType]
_SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]]
def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ...
def getabsfile(object: _SourceObjectType) -> str: ...