@@ -38,25 +38,60 @@ __all__ = [
38
38
_HaveCodeType : TypeAlias = types .MethodType | types .FunctionType | types .CodeType | type | Callable [..., Any ]
39
39
_HaveCodeOrStringType : TypeAlias = _HaveCodeType | str | bytes
40
40
41
- class Instruction (NamedTuple ):
42
- opname : str
43
- opcode : int
44
- arg : int | None
45
- argval : Any
46
- argrepr : str
47
- offset : int
48
- starts_line : int | None
49
- is_jump_target : bool
41
+ if sys .version_info >= (3 , 11 ):
42
+ class Positions (NamedTuple ):
43
+ lineno : int | None = ...
44
+ end_lineno : int | None = ...
45
+ col_offset : int | None = ...
46
+ end_col_offset : int | None = ...
47
+
48
+ if sys .version_info >= (3 , 11 ):
49
+ class Instruction (NamedTuple ):
50
+ opname : str
51
+ opcode : int
52
+ arg : int | None
53
+ argval : Any
54
+ argrepr : str
55
+ offset : int
56
+ starts_line : int | None
57
+ is_jump_target : bool
58
+ positions : Positions | None = ...
59
+
60
+ else :
61
+ class Instruction (NamedTuple ):
62
+ opname : str
63
+ opcode : int
64
+ arg : int | None
65
+ argval : Any
66
+ argrepr : str
67
+ offset : int
68
+ starts_line : int | None
69
+ is_jump_target : bool
50
70
51
71
class Bytecode :
52
72
codeobj : types .CodeType
53
73
first_line : int
54
- def __init__ (self , x : _HaveCodeOrStringType , * , first_line : int | None = ..., current_offset : int | None = ...) -> None : ...
74
+ if sys .version_info >= (3 , 11 ):
75
+ def __init__ (
76
+ self ,
77
+ x : _HaveCodeOrStringType ,
78
+ * ,
79
+ first_line : int | None = ...,
80
+ current_offset : int | None = ...,
81
+ show_caches : bool = ...,
82
+ ) -> None : ...
83
+ @classmethod
84
+ def from_traceback (cls : type [Self ], tb : types .TracebackType , * , show_caches : bool = ...) -> Self : ...
85
+ else :
86
+ def __init__ (
87
+ self , x : _HaveCodeOrStringType , * , first_line : int | None = ..., current_offset : int | None = ...
88
+ ) -> None : ...
89
+ @classmethod
90
+ def from_traceback (cls : type [Self ], tb : types .TracebackType ) -> Self : ...
91
+
55
92
def __iter__ (self ) -> Iterator [Instruction ]: ...
56
93
def info (self ) -> str : ...
57
94
def dis (self ) -> str : ...
58
- @classmethod
59
- def from_traceback (cls : type [Self ], tb : types .TracebackType ) -> Self : ...
60
95
61
96
COMPILER_FLAG_NAMES : dict [int , str ]
62
97
@@ -65,14 +100,27 @@ def findlinestarts(code: _HaveCodeType) -> Iterator[tuple[int, int]]: ...
65
100
def pretty_flags (flags : int ) -> str : ...
66
101
def code_info (x : _HaveCodeOrStringType ) -> str : ...
67
102
68
- if sys .version_info >= (3 , 7 ):
103
+ if sys .version_info >= (3 , 11 ):
104
+ def dis (
105
+ x : _HaveCodeOrStringType | None = ..., * , file : IO [str ] | None = ..., depth : int | None = ..., show_caches : bool = ...
106
+ ) -> None : ...
107
+
108
+ elif sys .version_info >= (3 , 7 ):
69
109
def dis (x : _HaveCodeOrStringType | None = ..., * , file : IO [str ] | None = ..., depth : int | None = ...) -> None : ...
70
110
71
111
else :
72
112
def dis (x : _HaveCodeOrStringType | None = ..., * , file : IO [str ] | None = ...) -> None : ...
73
113
74
- def distb (tb : types .TracebackType | None = ..., * , file : IO [str ] | None = ...) -> None : ...
75
- def disassemble (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ...) -> None : ...
76
- def disco (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ...) -> None : ...
114
+ if sys .version_info >= (3 , 11 ):
115
+ def disassemble (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ..., show_caches : bool = ...) -> None : ...
116
+ def disco (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ..., show_caches : bool = ...) -> None : ...
117
+ def distb (tb : types .TracebackType | None = ..., * , file : IO [str ] | None = ..., show_caches : bool = ...) -> None : ...
118
+ def get_instructions (x : _HaveCodeType , * , first_line : int | None = ..., show_caches : bool = ...) -> Iterator [Instruction ]: ...
119
+
120
+ else :
121
+ def disassemble (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ...) -> None : ...
122
+ def disco (co : _HaveCodeType , lasti : int = ..., * , file : IO [str ] | None = ...) -> None : ...
123
+ def distb (tb : types .TracebackType | None = ..., * , file : IO [str ] | None = ...) -> None : ...
124
+ def get_instructions (x : _HaveCodeType , * , first_line : int | None = ...) -> Iterator [Instruction ]: ...
125
+
77
126
def show_code (co : _HaveCodeType , * , file : IO [str ] | None = ...) -> None : ...
78
- def get_instructions (x : _HaveCodeType , * , first_line : int | None = ...) -> Iterator [Instruction ]: ...
0 commit comments