From c3d9e5075ea25bf814eb62b0bd2da13ccb10cc81 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 10 Oct 2019 20:12:35 +0200 Subject: [PATCH] Allow callables in _SourceObjectType (Python 2) 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 67be3a41a7c9..b1acc30407cb 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: ...