File: dis.pyi

package info (click to toggle)
mypy 0.470-complete-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,864 kB
  • ctags: 3,264
  • sloc: python: 21,838; makefile: 18
file content (63 lines) | stat: -rw-r--r-- 2,117 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from typing import List, Union, Iterator, Tuple, Optional, Any, IO, NamedTuple

from opcode import (hasconst, hasname, hasjrel, hasjabs, haslocal, hascompare,
                    hasfree, hasnargs, cmp_op, opname, opmap, HAVE_ARGUMENT,
                    EXTENDED_ARG, stack_effect)

import types

_have_code = Union[types.MethodType, types.FunctionType, types.CodeType, type]
_have_code_or_string = Union[_have_code, str, bytes]


Instruction = NamedTuple(
    "Instruction",
    [
        ('opname', str),
        ('opcode', int),
        ('arg', Optional[int]),
        ('argval', Any),
        ('argrepr', str),
        ('offset', int),
        ('starts_line', Optional[int]),
        ('is_jump_target', bool)
    ]
)


# if sys.version_info >= (3, 4):
class Bytecode:
    codeobj = ...  # type: types.CodeType
    first_line = ...  # type: int
    def __init__(self, x: _have_code_or_string, *, first_line: int=...,
                 current_offset: int=...) -> None: ...
    def __iter__(self) -> Iterator[Instruction]: ...
    def __repr__(self) -> str: ...
    def info(self) -> str: ...
    def dis(self) -> str: ...

    @classmethod
    def from_traceback(cls, tb: types.TracebackType) -> Bytecode: ...


COMPILER_FLAG_NAMES = ...  # type:  Dict[int, str]


def pretty_flags(flags: int) -> str: ...
def findlabels(code: _have_code) -> List[int]: ...
def findlinestarts(code: _have_code) -> Iterator[Tuple[int, int]]: ...

# Signature changes are not allowed by mypy
# 'All conditional function variants must have identical signatures'
# TODO: mypy issue #698

# if sys.version_info >= (3, 2):
def code_info(x: _have_code_or_string) -> str: ...

# `file` parameter requires sys.version_info >= (3, 4):
def dis(x: _have_code_or_string = ..., *, file: IO[str] = None) -> None: ...
def distb(tb: types.TracebackType = ..., *, file: IO[str] = None) -> None: ...
def disassemble(co: _have_code, lasti: int = ..., *, file: IO[str] = None) -> None: ...
def show_code(co: _have_code, *, file: IO[str] = None) -> None: ...

def get_instructions(x: _have_code, *, first_line: int = ...) -> Iterator[Instruction]: ...