Skip to content

Commit

Permalink
dis: update for py311 (#7649)
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Apr 17, 2022
1 parent b562089 commit a24ce3f
Showing 1 changed file with 65 additions and 17 deletions.
82 changes: 65 additions & 17 deletions stdlib/dis.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,60 @@ __all__ = [
_HaveCodeType: TypeAlias = types.MethodType | types.FunctionType | types.CodeType | type | Callable[..., Any]
_HaveCodeOrStringType: TypeAlias = _HaveCodeType | str | bytes

class Instruction(NamedTuple):
opname: str
opcode: int
arg: int | None
argval: Any
argrepr: str
offset: int
starts_line: int | None
is_jump_target: bool
if sys.version_info >= (3, 11):
class Positions(NamedTuple):
lineno: int | None = ...
end_lineno: int | None = ...
col_offset: int | None = ...
end_col_offset: int | None = ...

if sys.version_info >= (3, 11):
class Instruction(NamedTuple):
opname: str
opcode: int
arg: int | None
argval: Any
argrepr: str
offset: int
starts_line: int | None
is_jump_target: bool
positions: Positions | None = ...

else:
class Instruction(NamedTuple):
opname: str
opcode: int
arg: int | None
argval: Any
argrepr: str
offset: int
starts_line: int | None
is_jump_target: bool

class Bytecode:
codeobj: types.CodeType
first_line: int
def __init__(self, x: _HaveCodeOrStringType, *, first_line: int | None = ..., current_offset: int | None = ...) -> None: ...
if sys.version_info >= (3, 11):
def __init__(
self,
x: _HaveCodeOrStringType,
*,
first_line: int | None = ...,
current_offset: int | None = ...,
show_caches: bool = ...,
) -> None: ...
@classmethod
def from_traceback(cls: type[Self], tb: types.TracebackType, *, show_caches: bool = ...) -> Self: ...
else:
def __init__(
self, x: _HaveCodeOrStringType, *, first_line: int | None = ..., current_offset: int | None = ...
) -> None: ...
@classmethod
def from_traceback(cls: type[Self], tb: types.TracebackType) -> Self: ...

def __iter__(self) -> Iterator[Instruction]: ...
def info(self) -> str: ...
def dis(self) -> str: ...
@classmethod
def from_traceback(cls: type[Self], tb: types.TracebackType) -> Self: ...

COMPILER_FLAG_NAMES: dict[int, str]

Expand All @@ -65,14 +100,27 @@ def findlinestarts(code: _HaveCodeType) -> Iterator[tuple[int, int]]: ...
def pretty_flags(flags: int) -> str: ...
def code_info(x: _HaveCodeOrStringType) -> str: ...

if sys.version_info >= (3, 7):
if sys.version_info >= (3, 11):
def dis(
x: _HaveCodeOrStringType | None = ..., *, file: IO[str] | None = ..., depth: int | None = ..., show_caches: bool = ...
) -> None: ...

elif sys.version_info >= (3, 7):
def dis(x: _HaveCodeOrStringType | None = ..., *, file: IO[str] | None = ..., depth: int | None = ...) -> None: ...

else:
def dis(x: _HaveCodeOrStringType | None = ..., *, file: IO[str] | None = ...) -> None: ...

def distb(tb: types.TracebackType | None = ..., *, file: IO[str] | None = ...) -> None: ...
def disassemble(co: _HaveCodeType, lasti: int = ..., *, file: IO[str] | None = ...) -> None: ...
def disco(co: _HaveCodeType, lasti: int = ..., *, file: IO[str] | None = ...) -> None: ...
if sys.version_info >= (3, 11):
def disassemble(co: _HaveCodeType, lasti: int = ..., *, file: IO[str] | None = ..., show_caches: bool = ...) -> None: ...
def disco(co: _HaveCodeType, lasti: int = ..., *, file: IO[str] | None = ..., show_caches: bool = ...) -> None: ...
def distb(tb: types.TracebackType | None = ..., *, file: IO[str] | None = ..., show_caches: bool = ...) -> None: ...
def get_instructions(x: _HaveCodeType, *, first_line: int | None = ..., show_caches: bool = ...) -> Iterator[Instruction]: ...

else:
def disassemble(co: _HaveCodeType, lasti: int = ..., *, file: IO[str] | None = ...) -> None: ...
def disco(co: _HaveCodeType, lasti: int = ..., *, file: IO[str] | None = ...) -> None: ...
def distb(tb: types.TracebackType | None = ..., *, file: IO[str] | None = ...) -> None: ...
def get_instructions(x: _HaveCodeType, *, first_line: int | None = ...) -> Iterator[Instruction]: ...

def show_code(co: _HaveCodeType, *, file: IO[str] | None = ...) -> None: ...
def get_instructions(x: _HaveCodeType, *, first_line: int | None = ...) -> Iterator[Instruction]: ...

0 comments on commit a24ce3f

Please sign in to comment.