From c38cf6736e3eee4d0fb507861b051008d73d23cd Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 2 Oct 2019 15:52:21 -0700 Subject: [PATCH] Allow callables in _SourceObjectType (#3295) 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/3/inspect.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/inspect.pyi b/stdlib/3/inspect.pyi index 5c518b81b..099041551 100644 --- a/stdlib/3/inspect.pyi +++ b/stdlib/3/inspect.pyi @@ -77,7 +77,7 @@ 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: ...