4 EXTENDED_ARG as EXTENDED_ARG,
5 HAVE_ARGUMENT as HAVE_ARGUMENT,
7 hascompare as hascompare,
17 stack_effect as stack_effect,
19 from typing import IO, Any, Callable, Iterator, NamedTuple, Union
21 # Strictly this should not have to include Callable, but mypy doesn't use FunctionType
22 # for functions (python/mypy#3171)
23 _have_code = Union[types.MethodType, types.FunctionType, types.CodeType, type, Callable[..., Any]]
24 _have_code_or_string = Union[_have_code, str, bytes]
26 class Instruction(NamedTuple):
33 starts_line: int | None
37 codeobj: types.CodeType
39 def __init__(self, x: _have_code_or_string, *, first_line: int | None = ..., current_offset: int | None = ...) -> None: ...
40 def __iter__(self) -> Iterator[Instruction]: ...
41 def __repr__(self) -> str: ...
42 def info(self) -> str: ...
43 def dis(self) -> str: ...
45 def from_traceback(cls, tb: types.TracebackType) -> Bytecode: ...
47 COMPILER_FLAG_NAMES: dict[int, str]
49 def findlabels(code: _have_code) -> list[int]: ...
50 def findlinestarts(code: _have_code) -> Iterator[tuple[int, int]]: ...
51 def pretty_flags(flags: int) -> str: ...
52 def code_info(x: _have_code_or_string) -> str: ...
54 if sys.version_info >= (3, 7):
55 def dis(x: _have_code_or_string | None = ..., *, file: IO[str] | None = ..., depth: int | None = ...) -> None: ...
58 def dis(x: _have_code_or_string | None = ..., *, file: IO[str] | None = ...) -> None: ...
60 def distb(tb: types.TracebackType | None = ..., *, file: IO[str] | None = ...) -> None: ...
61 def disassemble(co: _have_code, lasti: int = ..., *, file: IO[str] | None = ...) -> None: ...
62 def disco(co: _have_code, lasti: int = ..., *, file: IO[str] | None = ...) -> None: ...
63 def show_code(co: _have_code, *, file: IO[str] | None = ...) -> None: ...
64 def get_instructions(x: _have_code, *, first_line: int | None = ...) -> Iterator[Instruction]: ...