@@ -37,7 +37,6 @@ __all__ = [
3737# Strictly this should not have to include Callable, but mypy doesn't use FunctionType
3838# for functions (python/mypy#3171)
3939_HaveCodeType : TypeAlias = types .MethodType | types .FunctionType | types .CodeType | type | Callable [..., Any ]
40- _HaveCodeOrStringType : TypeAlias = _HaveCodeType | str | bytes
4140
4241if sys .version_info >= (3 , 11 ):
4342 class Positions (NamedTuple ):
@@ -75,7 +74,7 @@ class Bytecode:
7574 if sys .version_info >= (3 , 11 ):
7675 def __init__ (
7776 self ,
78- x : _HaveCodeOrStringType ,
77+ x : _HaveCodeType | str ,
7978 * ,
8079 first_line : int | None = ...,
8180 current_offset : int | None = ...,
@@ -87,9 +86,7 @@ class Bytecode:
8786 cls : type [Self ], tb : types .TracebackType , * , show_caches : bool = ..., adaptive : bool = ...
8887 ) -> Self : ...
8988 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 : ...
9390 @classmethod
9491 def from_traceback (cls : type [Self ], tb : types .TracebackType ) -> Self : ...
9592
@@ -102,11 +99,11 @@ COMPILER_FLAG_NAMES: dict[int, str]
10299def findlabels (code : _HaveCodeType ) -> list [int ]: ...
103100def findlinestarts (code : _HaveCodeType ) -> Iterator [tuple [int , int ]]: ...
104101def pretty_flags (flags : int ) -> str : ...
105- def code_info (x : _HaveCodeOrStringType ) -> str : ...
102+ def code_info (x : _HaveCodeType | str ) -> str : ...
106103
107104if sys .version_info >= (3 , 11 ):
108105 def dis (
109- x : _HaveCodeOrStringType | None = ...,
106+ x : _HaveCodeType | str | bytes | bytearray | None = ...,
110107 * ,
111108 file : IO [str ] | None = ...,
112109 depth : int | None = ...,
@@ -115,7 +112,9 @@ if sys.version_info >= (3, 11):
115112 ) -> None : ...
116113
117114else :
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 : ...
119118
120119if sys .version_info >= (3 , 11 ):
121120 def disassemble (
0 commit comments