From d7e9af44927d9901daf0d5e43486642564a6a192 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 7 May 2019 11:21:54 -0400 Subject: [PATCH] allow callables in dis() (#2969) Fixes #2914 --- stdlib/2and3/dis.pyi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/2and3/dis.pyi b/stdlib/2and3/dis.pyi index 989812aca..0ef27f4af 100644 --- a/stdlib/2and3/dis.pyi +++ b/stdlib/2and3/dis.pyi @@ -1,4 +1,4 @@ -from typing import List, Union, Iterator, Tuple, Optional, Any, IO, NamedTuple, Dict +from typing import Callable, List, Union, Iterator, Tuple, Optional, Any, IO, NamedTuple, Dict import sys import types @@ -14,7 +14,9 @@ if sys.version_info >= (3, 4): if sys.version_info >= (3, 6): from opcode import hasnargs as hasnargs -_have_code = Union[types.MethodType, types.FunctionType, types.CodeType, type] +# Strictly this should not have to include Callable, but mypy doesn't use FunctionType +# for functions (python/mypy#3171) +_have_code = Union[types.MethodType, types.FunctionType, types.CodeType, type, Callable[..., Any]] _have_code_or_string = Union[_have_code, str, bytes]