Format: application/octet-stream
1 from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Type, TypeVar, Union, overload
2
3 _T = TypeVar("_T")
4
5 # Note, all classes "defined" here require special handling.
6
7 class NoneType: ...
8
9 TypeType = type
10 ObjectType = object
11
12 IntType = int
13 LongType = int # Really long, but can't reference that due to a mypy import cycle
14 FloatType = float
15 BooleanType = bool
16 ComplexType = complex
17 StringType = str
18 UnicodeType = unicode
19 StringTypes: Tuple[Type[StringType], Type[UnicodeType]]
20 BufferType = buffer
21 TupleType = tuple
22 ListType = list
23 DictType = dict
24 DictionaryType = dict
25
26 class _Cell:
27 cell_contents: Any
28
29 class FunctionType:
30 func_closure: Optional[Tuple[_Cell, ...]] = ...
31 func_code: CodeType = ...
32 func_defaults: Optional[Tuple[Any, ...]] = ...
33 func_dict: Dict[str, Any] = ...
34 func_doc: Optional[str] = ...
35 func_globals: Dict[str, Any] = ...
36 func_name: str = ...
37 __closure__ = func_closure
38 __code__ = func_code
39 __defaults__ = func_defaults
40 __dict__ = func_dict
41 __globals__ = func_globals
42 __name__ = func_name
43 def __init__(
44 self,
45 code: CodeType,
46 globals: Dict[str, Any],
47 name: Optional[str] = ...,
48 argdefs: Optional[Tuple[object, ...]] = ...,
49 closure: Optional[Tuple[_Cell, ...]] = ...,
50 ) -> None: ...
51 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
52 def __get__(self, obj: Optional[object], type: Optional[type]) -> UnboundMethodType: ...
53
54 LambdaType = FunctionType
55
56 class CodeType:
57 co_argcount: int
58 co_cellvars: Tuple[str, ...]
59 co_code: str
60 co_consts: Tuple[Any, ...]
61 co_filename: str
62 co_firstlineno: int
63 co_flags: int
64 co_freevars: Tuple[str, ...]
65 co_lnotab: str
66 co_name: str
67 co_names: Tuple[str, ...]
68 co_nlocals: int
69 co_stacksize: int
70 co_varnames: Tuple[str, ...]
71 def __init__(
72 self,
73 argcount: int,
74 nlocals: int,
75 stacksize: int,
76 flags: int,
77 codestring: str,
78 constants: Tuple[Any, ...],
79 names: Tuple[str, ...],
80 varnames: Tuple[str, ...],
81 filename: str,
82 name: str,
83 firstlineno: int,
84 lnotab: str,
85 freevars: Tuple[str, ...] = ...,
86 cellvars: Tuple[str, ...] = ...,
87 ) -> None: ...
88
89 class GeneratorType:
90 gi_code: CodeType
91 gi_frame: FrameType
92 gi_running: int
93 def __iter__(self) -> GeneratorType: ...
94 def close(self) -> None: ...
95 def next(self) -> Any: ...
96 def send(self, __arg: Any) -> Any: ...
97 @overload
98 def throw(
99 self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ...
100 ) -> Any: ...
101 @overload
102 def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Any: ...
103
104 class ClassType: ...
105
106 class UnboundMethodType:
107 im_class: type = ...
108 im_func: FunctionType = ...
109 im_self: object = ...
110 __name__: str
111 __func__ = im_func
112 __self__ = im_self
113 def __init__(self, func: Callable[..., Any], obj: object) -> None: ...
114 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
115
116 class InstanceType(object): ...
117
118 MethodType = UnboundMethodType
119
120 class BuiltinFunctionType:
121 __self__: Optional[object]
122 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
123
124 BuiltinMethodType = BuiltinFunctionType
125
126 class ModuleType:
127 __doc__: Optional[str]
128 __file__: Optional[str]
129 __name__: str
130 __package__: Optional[str]
131 __path__: Optional[Iterable[str]]
132 __dict__: Dict[str, Any]
133 def __init__(self, name: str, doc: Optional[str] = ...) -> None: ...
134
135 FileType = file
136 XRangeType = xrange
137
138 class TracebackType:
139 tb_frame: FrameType
140 tb_lasti: int
141 tb_lineno: int
142 tb_next: TracebackType
143
144 class FrameType:
145 f_back: FrameType
146 f_builtins: Dict[str, Any]
147 f_code: CodeType
148 f_exc_type: None
149 f_exc_value: None
150 f_exc_traceback: None
151 f_globals: Dict[str, Any]
152 f_lasti: int
153 f_lineno: int
154 f_locals: Dict[str, Any]
155 f_restricted: bool
156 f_trace: Callable[[], None]
157 def clear(self) -> None: ...
158
159 SliceType = slice
160
161 class EllipsisType: ...
162
163 class DictProxyType:
164 # TODO is it possible to have non-string keys?
165 # no __init__
166 def copy(self) -> Dict[Any, Any]: ...
167 def get(self, key: str, default: _T = ...) -> Union[Any, _T]: ...
168 def has_key(self, key: str) -> bool: ...
169 def items(self) -> List[Tuple[str, Any]]: ...
170 def iteritems(self) -> Iterator[Tuple[str, Any]]: ...
171 def iterkeys(self) -> Iterator[str]: ...
172 def itervalues(self) -> Iterator[Any]: ...
173 def keys(self) -> List[str]: ...
174 def values(self) -> List[Any]: ...
175 def __contains__(self, key: str) -> bool: ...
176 def __getitem__(self, key: str) -> Any: ...
177 def __iter__(self) -> Iterator[str]: ...
178 def __len__(self) -> int: ...
179
180 class NotImplementedType: ...
181
182 class GetSetDescriptorType:
183 __name__: str
184 __objclass__: type
185 def __get__(self, obj: Any, type: type = ...) -> Any: ...
186 def __set__(self, obj: Any) -> None: ...
187 def __delete__(self, obj: Any) -> None: ...
188
189 # Same type on Jython, different on CPython and PyPy, unknown on IronPython.
190 class MemberDescriptorType:
191 __name__: str
192 __objclass__: type
193 def __get__(self, obj: Any, type: type = ...) -> Any: ...
194 def __set__(self, obj: Any) -> None: ...
195 def __delete__(self, obj: Any) -> None: ...
196