From 7d1a93c6d35a36d7243bd13dafd81420c348887a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 7 May 2019 09:26:04 -0400 Subject: [PATCH 1/2] allow callables in dis() Fixes #2914 --- stdlib/2and3/dis.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/2and3/dis.pyi b/stdlib/2and3/dis.pyi index 989812aca486..bbb91105ec75 100644 --- a/stdlib/2and3/dis.pyi +++ b/stdlib/2and3/dis.pyi @@ -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] From 5d7bc3815caa8145dc1cde9c3cf5fe7c384f9301 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 7 May 2019 09:57:46 -0400 Subject: [PATCH 2/2] add import --- stdlib/2and3/dis.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/2and3/dis.pyi b/stdlib/2and3/dis.pyi index bbb91105ec75..0ef27f4af49f 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