massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / coc-python-data / languageServer.0.5.59 / Typeshed / stdlib / 3 / types.pyi
1 # Stubs for types\r
2 # Note, all classes "defined" here require special handling.\r
3 \r
4 # TODO parts of this should be conditional on version\r
5 \r
6 import sys\r
7 from typing import (\r
8     Any, Awaitable, Callable, Dict, Generic, Iterator, Mapping, Optional, Tuple, TypeVar,\r
9     Union, overload, Type\r
10 )\r
11 \r
12 # ModuleType is exported from this module, but for circular import\r
13 # reasons exists in its own stub file (with ModuleSpec and Loader).\r
14 from _importlib_modulespec import ModuleType as ModuleType  # Exported\r
15 \r
16 _T = TypeVar('_T')\r
17 _T_co = TypeVar('_T_co', covariant=True)\r
18 _T_contra = TypeVar('_T_contra', contravariant=True)\r
19 _KT = TypeVar('_KT')\r
20 _VT = TypeVar('_VT')\r
21 \r
22 class _Cell:\r
23     cell_contents = ...  # type: Any\r
24 \r
25 class FunctionType:\r
26     __closure__ = ...  # type: Optional[Tuple[_Cell, ...]]\r
27     __code__ = ...  # type: CodeType\r
28     __defaults__ = ...  # type: Optional[Tuple[Any, ...]]\r
29     __dict__ = ...  # type: Dict[str, Any]\r
30     __globals__ = ...  # type: Dict[str, Any]\r
31     __name__ = ...  # type: str\r
32     __qualname__ = ...  # type: str\r
33     __annotations__ = ...  # type: Dict[str, Any]\r
34     __kwdefaults__ = ...  # type: Dict[str, Any]\r
35     def __call__(self, *args: Any, **kwargs: Any) -> Any: ...\r
36     def __get__(self, obj: Optional[object], type: Optional[type]) -> 'MethodType': ...\r
37 LambdaType = FunctionType\r
38 \r
39 class CodeType:\r
40     """Create a code object.  Not for the faint of heart."""\r
41     co_argcount = ...  # type: int\r
42     co_kwonlyargcount = ...  # type: int\r
43     co_nlocals = ...  # type: int\r
44     co_stacksize = ...  # type: int\r
45     co_flags = ...  # type: int\r
46     co_code = ...  # type: bytes\r
47     co_consts = ...  # type: Tuple[Any, ...]\r
48     co_names = ...  # type: Tuple[str, ...]\r
49     co_varnames = ...  # type: Tuple[str, ...]\r
50     co_filename = ...  # type: Optional[str]\r
51     co_name = ...  # type: str\r
52     co_firstlineno = ...  # type: int\r
53     co_lnotab = ...  # type: bytes\r
54     co_freevars = ...  # type: Tuple[str, ...]\r
55     co_cellvars = ...  # type: Tuple[str, ...]\r
56     def __init__(\r
57         self,\r
58         argcount: int,\r
59         kwonlyargcount: int,\r
60         nlocals: int,\r
61         stacksize: int,\r
62         flags: int,\r
63         codestring: bytes,\r
64         constants: Tuple[Any, ...],\r
65         names: Tuple[str, ...],\r
66         varnames: Tuple[str, ...],\r
67         filename: str,\r
68         name: str,\r
69         firstlineno: int,\r
70         lnotab: bytes,\r
71         freevars: Tuple[str, ...] = ...,\r
72         cellvars: Tuple[str, ...] = ...,\r
73     ) -> None: ...\r
74 \r
75 class MappingProxyType(Mapping[_KT, _VT], Generic[_KT, _VT]):\r
76     def __init__(self, mapping: Mapping[_KT, _VT]) -> None: ...\r
77     def __getitem__(self, k: _KT) -> _VT: ...\r
78     def __iter__(self) -> Iterator[_KT]: ...\r
79     def __len__(self) -> int: ...\r
80 \r
81 class SimpleNamespace:\r
82     def __init__(self, **kwargs: Any) -> None: ...\r
83     def __getattribute__(self, name: str) -> Any: ...\r
84     def __setattr__(self, name: str, value: Any) -> None: ...\r
85     def __delattr__(self, name: str) -> None: ...\r
86 \r
87 class GeneratorType:\r
88     gi_code = ...  # type: CodeType\r
89     gi_frame = ...  # type: FrameType\r
90     gi_running = ...  # type: bool\r
91     gi_yieldfrom = ...  # type: Optional[GeneratorType]\r
92     def __iter__(self) -> 'GeneratorType': ...\r
93     def __next__(self) -> Any: ...\r
94     def close(self) -> None: ...\r
95     def send(self, arg: Any) -> Any: ...\r
96     @overload\r
97     def throw(self, val: BaseException) -> Any: ...\r
98     @overload\r
99     def throw(self, typ: type, val: BaseException = ..., tb: 'TracebackType' = ...) -> Any: ...\r
100 \r
101 if sys.version_info >= (3, 6):\r
102     class AsyncGeneratorType(Generic[_T_co, _T_contra]):\r
103         ag_await: Optional[Awaitable[Any]]\r
104         ag_frame: FrameType\r
105         ag_running: bool\r
106         ag_code: CodeType\r
107         def __aiter__(self) -> Awaitable[AsyncGeneratorType[_T_co, _T_contra]]: ...\r
108         def __anext__(self) -> Awaitable[_T_co]: ...\r
109         def asend(self, val: _T_contra) -> Awaitable[_T_co]: ...\r
110         @overload\r
111         def athrow(self, val: BaseException) -> Awaitable[_T_co]: ...\r
112         @overload\r
113         def athrow(self, typ: Type[BaseException], val: BaseException, tb: TracebackType = ...) -> Awaitable[_T_co]: ...\r
114         def aclose(self) -> Awaitable[_T_co]: ...\r
115 \r
116 class CoroutineType:\r
117     cr_await = ...  # type: Optional[Any]\r
118     cr_code = ...  # type: CodeType\r
119     cr_frame = ...  # type: FrameType\r
120     cr_running = ...  # type: bool\r
121     def close(self) -> None: ...\r
122     def send(self, arg: Any) -> Any: ...\r
123     @overload\r
124     def throw(self, val: BaseException) -> Any: ...\r
125     @overload\r
126     def throw(self, typ: type, val: BaseException = ..., tb: 'TracebackType' = ...) -> Any: ...\r
127 \r
128 class _StaticFunctionType:\r
129     """Fictional type to correct the type of MethodType.__func__.\r
130 \r
131     FunctionType is a descriptor, so mypy follows the descriptor protocol and\r
132     converts MethodType.__func__ back to MethodType (the return type of\r
133     FunctionType.__get__). But this is actually a special case; MethodType is\r
134     implemented in C and its attribute access doesn't go through\r
135     __getattribute__.\r
136 \r
137     By wrapping FunctionType in _StaticFunctionType, we get the right result;\r
138     similar to wrapping a function in staticmethod() at runtime to prevent it\r
139     being bound as a method.\r
140     """\r
141     def __get__(self, obj: Optional[object], type: Optional[type]) -> 'FunctionType': ...\r
142 \r
143 class MethodType:\r
144     __func__ = ...  # type: _StaticFunctionType\r
145     __self__ = ...  # type: object\r
146     __name__ = ...  # type: str\r
147     __qualname__ = ...  # type: str\r
148     def __init__(self, func: Callable, obj: object) -> None: ...\r
149     def __call__(self, *args: Any, **kwargs: Any) -> Any: ...\r
150 class BuiltinFunctionType:\r
151     __self__ = ...  # type: Union[object, ModuleType]\r
152     __name__ = ...  # type: str\r
153     __qualname__ = ...  # type: str\r
154     def __call__(self, *args: Any, **kwargs: Any) -> Any: ...\r
155 BuiltinMethodType = BuiltinFunctionType\r
156 \r
157 class TracebackType:\r
158     if sys.version_info >= (3, 7):\r
159         def __init__(self, tb_next: Optional[TracebackType], tb_frame: FrameType, tb_lasti: int, tb_lineno: int) -> None: ...\r
160         tb_next: Optional[TracebackType]\r
161     else:\r
162         @property\r
163         def tb_next(self) -> Optional[TracebackType]: ...\r
164     # the rest are read-only even in 3.7\r
165     @property\r
166     def tb_frame(self) -> FrameType: ...\r
167     @property\r
168     def tb_lasti(self) -> int: ...\r
169     @property\r
170     def tb_lineno(self) -> int: ...\r
171 \r
172 class FrameType:\r
173     f_back = ...  # type: FrameType\r
174     f_builtins = ...  # type: Dict[str, Any]\r
175     f_code = ...  # type: CodeType\r
176     f_globals = ...  # type: Dict[str, Any]\r
177     f_lasti = ...  # type: int\r
178     f_lineno = ...  # type: int\r
179     f_locals = ...  # type: Dict[str, Any]\r
180     f_trace = ...  # type: Callable[[], None]\r
181     if sys.version_info >= (3, 7):\r
182         f_frace_lines: bool\r
183         f_trace_opcodes: bool\r
184 \r
185     def clear(self) -> None: ...\r
186 \r
187 class GetSetDescriptorType:\r
188     __name__ = ...  # type: str\r
189     __objclass__ = ...  # type: type\r
190     def __get__(self, obj: Any, type: type = ...) -> Any: ...\r
191     def __set__(self, obj: Any) -> None: ...\r
192     def __delete__(self, obj: Any) -> None: ...\r
193 class MemberDescriptorType:\r
194     __name__ = ...  # type: str\r
195     __objclass__ = ...  # type: type\r
196     def __get__(self, obj: Any, type: type = ...) -> Any: ...\r
197     def __set__(self, obj: Any) -> None: ...\r
198     def __delete__(self, obj: Any) -> None: ...\r
199 \r
200 def new_class(name: str, bases: Tuple[type, ...] = ..., kwds: Dict[str, Any] = ..., exec_body: Callable[[Dict[str, Any]], None] = ...) -> type: ...\r
201 def prepare_class(name: str, bases: Tuple[type, ...] = ..., kwds: Dict[str, Any] = ...) -> Tuple[type, Dict[str, Any], Dict[str, Any]]: ...\r
202 \r
203 # Actually a different type, but `property` is special and we want that too.\r
204 DynamicClassAttribute = property\r
205 \r
206 def coroutine(f: Callable[..., Any]) -> CoroutineType: ...\r