From 9b0922166ab16f995c7a7c407bb077e3f9484a25 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 11 Oct 2019 05:51:56 +0200 Subject: [PATCH] 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. --- stdlib/2/inspect.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/2/inspect.pyi b/stdlib/2/inspect.pyi index 67be3a41a..b1acc3040 100644 --- a/stdlib/2/inspect.pyi +++ b/stdlib/2/inspect.pyi @@ -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: ...