allow callables in dis() (#2969)

Fixes #2914
This commit is contained in:
Jelle Zijlstra
2019-05-07 11:21:54 -04:00
committed by Sebastian Rittau
parent bdb1de57f5
commit d7e9af4492

View File

@@ -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]