Format: application/octet-stream
1 from types import CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType
2 from typing import Any, AnyStr, Callable, Dict, List, NamedTuple, Optional, Sequence, Tuple, Type, Union
3
4 # Types and members
5 class EndOfBlock(Exception): ...
6
7 class BlockFinder:
8 indent: int
9 islambda: bool
10 started: bool
11 passline: bool
12 last: int
13 def tokeneater(
14 self, type: int, token: AnyStr, srow_scol: Tuple[int, int], erow_ecol: Tuple[int, int], line: AnyStr
15 ) -> None: ...
16
17 CO_GENERATOR: int
18 CO_NESTED: int
19 CO_NEWLOCALS: int
20 CO_NOFREE: int
21 CO_OPTIMIZED: int
22 CO_VARARGS: int
23 CO_VARKEYWORDS: int
24 TPFLAGS_IS_ABSTRACT: int
25
26 class ModuleInfo(NamedTuple):
27 name: str
28 suffix: str
29 mode: str
30 module_type: int
31
32 def getmembers(object: object, predicate: Optional[Callable[[Any], bool]] = ...) -> List[Tuple[str, Any]]: ...
33 def getmoduleinfo(path: Union[str, unicode]) -> Optional[ModuleInfo]: ...
34 def getmodulename(path: AnyStr) -> Optional[AnyStr]: ...
35 def ismodule(object: object) -> bool: ...
36 def isclass(object: object) -> bool: ...
37 def ismethod(object: object) -> bool: ...
38 def isfunction(object: object) -> bool: ...
39 def isgeneratorfunction(object: object) -> bool: ...
40 def isgenerator(object: object) -> bool: ...
41 def istraceback(object: object) -> bool: ...
42 def isframe(object: object) -> bool: ...
43 def iscode(object: object) -> bool: ...
44 def isbuiltin(object: object) -> bool: ...
45 def isroutine(object: object) -> bool: ...
46 def isabstract(object: object) -> bool: ...
47 def ismethoddescriptor(object: object) -> bool: ...
48 def isdatadescriptor(object: object) -> bool: ...
49 def isgetsetdescriptor(object: object) -> bool: ...
50 def ismemberdescriptor(object: object) -> bool: ...
51
52 # Retrieving source code
53 _SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]]
54
55 def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ...
56 def getabsfile(object: _SourceObjectType) -> str: ...
57 def getblock(lines: Sequence[AnyStr]) -> Sequence[AnyStr]: ...
58 def getdoc(object: object) -> Optional[str]: ...
59 def getcomments(object: object) -> Optional[str]: ...
60 def getfile(object: _SourceObjectType) -> str: ...
61 def getmodule(object: object) -> Optional[ModuleType]: ...
62 def getsourcefile(object: _SourceObjectType) -> Optional[str]: ...
63 def getsourcelines(object: _SourceObjectType) -> Tuple[List[str], int]: ...
64 def getsource(object: _SourceObjectType) -> str: ...
65 def cleandoc(doc: AnyStr) -> AnyStr: ...
66 def indentsize(line: Union[str, unicode]) -> int: ...
67
68 # Classes and functions
69 def getclasstree(classes: List[type], unique: bool = ...) -> List[Union[Tuple[type, Tuple[type, ...]], List[Any]]]: ...
70
71 class ArgSpec(NamedTuple):
72 args: List[str]
73 varargs: Optional[str]
74 keywords: Optional[str]
75 defaults: Tuple[Any, ...]
76
77 class ArgInfo(NamedTuple):
78 args: List[str]
79 varargs: Optional[str]
80 keywords: Optional[str]
81 locals: Dict[str, Any]
82
83 class Arguments(NamedTuple):
84 args: List[Union[str, List[Any]]]
85 varargs: Optional[str]
86 keywords: Optional[str]
87
88 def getargs(co: CodeType) -> Arguments: ...
89 def getargspec(func: object) -> ArgSpec: ...
90 def getargvalues(frame: FrameType) -> ArgInfo: ...
91 def formatargspec(
92 args, varargs=..., varkw=..., defaults=..., formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=..., join=...
93 ) -> str: ...
94 def formatargvalues(
95 args, varargs=..., varkw=..., defaults=..., formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=..., join=...
96 ) -> str: ...
97 def getmro(cls: type) -> Tuple[type, ...]: ...
98 def getcallargs(func, *args, **kwds) -> Dict[str, Any]: ...
99
100 # The interpreter stack
101
102 class Traceback(NamedTuple):
103 filename: str
104 lineno: int
105 function: str
106 code_context: Optional[List[str]]
107 index: Optional[int] # type: ignore
108
109 _FrameInfo = Tuple[FrameType, str, int, str, Optional[List[str]], Optional[int]]
110
111 def getouterframes(frame: FrameType, context: int = ...) -> List[_FrameInfo]: ...
112 def getframeinfo(frame: Union[FrameType, TracebackType], context: int = ...) -> Traceback: ...
113 def getinnerframes(traceback: TracebackType, context: int = ...) -> List[_FrameInfo]: ...
114 def getlineno(frame: FrameType) -> int: ...
115 def currentframe(depth: int = ...) -> FrameType: ...
116 def stack(context: int = ...) -> List[_FrameInfo]: ...
117 def trace(context: int = ...) -> List[_FrameInfo]: ...
118
119 # Create private type alias to avoid conflict with symbol of same
120 # name created in Attribute class.
121 _Object = object
122
123 class Attribute(NamedTuple):
124 name: str
125 kind: str
126 defining_class: type
127 object: _Object
128
129 def classify_class_attrs(cls: type) -> List[Attribute]: ...
130