@@ -37,7 +37,6 @@ __all__ = [
37
37
# Strictly this should not have to include Callable, but mypy doesn't use FunctionType
38
38
# for functions (python/mypy#3171)
39
39
_HaveCodeType : TypeAlias = types .MethodType | types .FunctionType | types .CodeType | type | Callable [..., Any ]
40
- _HaveCodeOrStringType : TypeAlias = _HaveCodeType | str | bytes
41
40
42
41
if sys .version_info >= (3 , 11 ):
43
42
class Positions (NamedTuple ):
@@ -75,7 +74,7 @@ class Bytecode:
75
74
if sys .version_info >= (3 , 11 ):
76
75
def __init__ (
77
76
self ,
78
- x : _HaveCodeOrStringType ,
77
+ x : _HaveCodeType | str ,
79
78
* ,
80
79
first_line : int | None = ...,
81
80
current_offset : int | None = ...,
@@ -87,9 +86,7 @@ class Bytecode:
87
86
cls : type [Self ], tb : types .TracebackType , * , show_caches : bool = ..., adaptive : bool = ...
88
87
) -> Self : ...
89
88
else :
90
- def __init__ (
91
- self , x : _HaveCodeOrStringType , * , first_line : int | None = ..., current_offset : int | None = ...
92
- ) -> None : ...
89
+ def __init__ (self , x : _HaveCodeType | str , * , first_line : int | None = ..., current_offset : int | None = ...) -> None : ...
93
90
@classmethod
94
91
def from_traceback (cls : type [Self ], tb : types .TracebackType ) -> Self : ...
95
92
@@ -102,11 +99,11 @@ COMPILER_FLAG_NAMES: dict[int, str]
102
99
def findlabels (code : _HaveCodeType ) -> list [int ]: ...
103
100
def findlinestarts (code : _HaveCodeType ) -> Iterator [tuple [int , int ]]: ...
104
101
def pretty_flags (flags : int ) -> str : ...
105
- def code_info (x : _HaveCodeOrStringType ) -> str : ...
102
+ def code_info (x : _HaveCodeType | str ) -> str : ...
106
103
107
104
if sys .version_info >= (3 , 11 ):
108
105
def dis (
109
- x : _HaveCodeOrStringType | None = ...,
106
+ x : _HaveCodeType | str | bytes | bytearray | None = ...,
110
107
* ,
111
108
file : IO [str ] | None = ...,
112
109
depth : int | None = ...,
@@ -115,7 +112,9 @@ if sys.version_info >= (3, 11):
115
112
) -> None : ...
116
113
117
114
else :
118
- def dis (x : _HaveCodeOrStringType | None = ..., * , file : IO [str ] | None = ..., depth : int | None = ...) -> None : ...
115
+ def dis (
116
+ x : _HaveCodeType | str | bytes | bytearray | None = ..., * , file : IO [str ] | None = ..., depth : int | None = ...
117
+ ) -> None : ...
119
118
120
119
if sys .version_info >= (3 , 11 ):
121
120
def disassemble (
0 commit comments