massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / coc-python-data / languageServer.0.5.59 / Typeshed / stdlib / 3 / inspect.pyi
1 import sys\r
2 from typing import (AbstractSet, Any, Callable, Dict, Generator, List, Mapping,\r
3                     MutableMapping, NamedTuple, Optional, Sequence, Tuple,\r
4                     Union,\r
5                     )\r
6 from types import CodeType, FrameType, ModuleType, TracebackType\r
7 \r
8 #\r
9 # Types and members\r
10 #\r
11 class EndOfBlock(Exception): ...\r
12 \r
13 class BlockFinder:\r
14     indent: int\r
15     islambda: bool\r
16     started: bool\r
17     passline: bool\r
18     indecorator: bool\r
19     decoratorhasargs: bool\r
20     last: int\r
21     def tokeneater(self, type: int, token: str, srow_scol: Tuple[int, int],\r
22                    erow_ecol: Tuple[int, int], line: str) -> None: ...\r
23 \r
24 CO_OPTIMIZED: int\r
25 CO_NEWLOCALS: int\r
26 CO_VARARGS: int\r
27 CO_VARKEYWORDS: int\r
28 CO_NESTED: int\r
29 CO_GENERATOR: int\r
30 CO_NOFREE: int\r
31 if sys.version_info >= (3, 5):\r
32     CO_COROUTINE: int\r
33     CO_ITERABLE_COROUTINE: int\r
34 if sys.version_info >= (3, 6):\r
35     CO_ASYNC_GENERATOR: int\r
36 TPFLAGS_IS_ABSTRACT: int\r
37 \r
38 if sys.version_info < (3, 6):\r
39     ModuleInfo = NamedTuple('ModuleInfo', [('name', str),\r
40                                            ('suffix', str),\r
41                                            ('mode', str),\r
42                                            ('module_type', int),\r
43                                            ])\r
44     def getmoduleinfo(path: str) -> Optional[ModuleInfo]: ...\r
45 \r
46 def getmembers(object: object,\r
47                predicate: Optional[Callable[[Any], bool]] = ...,\r
48                ) -> List[Tuple[str, Any]]: ...\r
49 def getmodulename(path: str) -> Optional[str]: ...\r
50 \r
51 def ismodule(object: object) -> bool: ...\r
52 def isclass(object: object) -> bool: ...\r
53 def ismethod(object: object) -> bool: ...\r
54 def isfunction(object: object) -> bool: ...\r
55 def isgeneratorfunction(object: object) -> bool: ...\r
56 def isgenerator(object: object) -> bool: ...\r
57 \r
58 if sys.version_info >= (3, 5):\r
59     def iscoroutinefunction(object: object) -> bool: ...\r
60     def iscoroutine(object: object) -> bool: ...\r
61     def isawaitable(object: object) -> bool: ...\r
62 if sys.version_info >= (3, 6):\r
63     def isasyncgenfunction(object: object) -> bool: ...\r
64     def isasyncgen(object: object) -> bool: ...\r
65 def istraceback(object: object) -> bool: ...\r
66 def isframe(object: object) -> bool: ...\r
67 def iscode(object: object) -> bool: ...\r
68 def isbuiltin(object: object) -> bool: ...\r
69 def isroutine(object: object) -> bool: ...\r
70 def isabstract(object: object) -> bool: ...\r
71 def ismethoddescriptor(object: object) -> bool: ...\r
72 def isdatadescriptor(object: object) -> bool: ...\r
73 def isgetsetdescriptor(object: object) -> bool: ...\r
74 def ismemberdescriptor(object: object) -> bool: ...\r
75 \r
76 \r
77 #\r
78 # Retrieving source code\r
79 #\r
80 def findsource(object: object) -> Tuple[List[str], int]: ...\r
81 def getabsfile(object: object) -> str: ...\r
82 def getblock(lines: Sequence[str]) -> Sequence[str]: ...\r
83 def getdoc(object: object) -> str: ...\r
84 def getcomments(object: object) -> str: ...\r
85 def getfile(object: object) -> str: ...\r
86 def getmodule(object: object) -> ModuleType: ...\r
87 def getsourcefile(object: object) -> str: ...\r
88 # TODO restrict to "module, class, method, function, traceback, frame,\r
89 # or code object"\r
90 def getsourcelines(object: object) -> Tuple[List[str], int]: ...\r
91 # TODO restrict to "a module, class, method, function, traceback, frame,\r
92 # or code object"\r
93 def getsource(object: object) -> str: ...\r
94 def cleandoc(doc: str) -> str: ...\r
95 def indentsize(line: str) -> int: ...\r
96 \r
97 \r
98 #\r
99 # Introspecting callables with the Signature object\r
100 #\r
101 def signature(callable: Callable[..., Any],\r
102               *,\r
103               follow_wrapped: bool = ...) -> 'Signature': ...\r
104 \r
105 class Signature:\r
106     def __init__(self,\r
107                  parameters: Optional[Sequence['Parameter']] = ...,\r
108                  *,\r
109                  return_annotation: Any = ...) -> None: ...\r
110     # TODO: can we be more specific here?\r
111     empty: object = ...\r
112 \r
113     parameters: Mapping[str, 'Parameter']\r
114 \r
115     # TODO: can we be more specific here?\r
116     return_annotation: Any\r
117 \r
118     def bind(self, *args: Any, **kwargs: Any) -> 'BoundArguments': ...\r
119     def bind_partial(self, *args: Any, **kwargs: Any) -> 'BoundArguments': ...\r
120     def replace(self,\r
121                 *,\r
122                 parameters: Optional[Sequence['Parameter']] = ...,\r
123                 return_annotation: Any = ...) -> 'Signature': ...\r
124 \r
125     if sys.version_info >= (3, 5):\r
126         @classmethod\r
127         def from_callable(cls,\r
128                           obj: Callable[..., Any],\r
129                           *,\r
130                           follow_wrapped: bool = ...) -> 'Signature': ...\r
131 \r
132 # The name is the same as the enum's name in CPython\r
133 class _ParameterKind: ...\r
134 \r
135 class Parameter:\r
136     def __init__(self,\r
137                  name: str,\r
138                  kind: _ParameterKind,\r
139                  *,\r
140                  default: Any = ...,\r
141                  annotation: Any = ...) -> None: ...\r
142     empty: Any = ...\r
143     name: str\r
144     default: Any\r
145     annotation: Any\r
146 \r
147     kind: _ParameterKind\r
148     POSITIONAL_ONLY: _ParameterKind = ...\r
149     POSITIONAL_OR_KEYWORD: _ParameterKind = ...\r
150     VAR_POSITIONAL: _ParameterKind = ...\r
151     KEYWORD_ONLY: _ParameterKind = ...\r
152     VAR_KEYWORD: _ParameterKind = ...\r
153 \r
154     def replace(self,\r
155                 *,\r
156                 name: Optional[str] = ...,\r
157                 kind: Optional[_ParameterKind] = ...,\r
158                 default: Any = ...,\r
159                 annotation: Any = ...) -> 'Parameter': ...\r
160 \r
161 class BoundArguments:\r
162     arguments: MutableMapping[str, Any]\r
163     args: Tuple[Any, ...]\r
164     kwargs: Dict[str, Any]\r
165     signature: Signature\r
166 \r
167     if sys.version_info >= (3, 5):\r
168         def apply_defaults(self) -> None: ...\r
169 \r
170 \r
171 #\r
172 # Classes and functions\r
173 #\r
174 \r
175 # TODO: The actual return type should be List[_ClassTreeItem] but mypy doesn't\r
176 # seem to be supporting this at the moment:\r
177 # _ClassTreeItem = Union[List['_ClassTreeItem'], Tuple[type, Tuple[type, ...]]]\r
178 def getclasstree(classes: List[type], unique: bool = ...) -> Any: ...\r
179 \r
180 ArgSpec = NamedTuple('ArgSpec', [('args', List[str]),\r
181                                  ('varargs', str),\r
182                                  ('keywords', str),\r
183                                  ('defaults', tuple),\r
184                                  ])\r
185 \r
186 Arguments = NamedTuple('Arguments', [('args', List[str]),\r
187                                      ('varargs', Optional[str]),\r
188                                      ('varkw', Optional[str]),\r
189                                      ])\r
190 \r
191 def getargs(co: CodeType) -> Arguments: ...\r
192 def getargspec(func: object) -> ArgSpec: ...\r
193 \r
194 FullArgSpec = NamedTuple('FullArgSpec', [('args', List[str]),\r
195                                          ('varargs', str),\r
196                                          ('varkw', str),\r
197                                          ('defaults', tuple),\r
198                                          ('kwonlyargs', List[str]),\r
199                                          ('kwonlydefaults', Dict[str, Any]),\r
200                                          ('annotations', Dict[str, Any]),\r
201                                          ])\r
202 \r
203 def getfullargspec(func: object) -> FullArgSpec: ...\r
204 \r
205 # TODO make the field types more specific here\r
206 ArgInfo = NamedTuple('ArgInfo', [('args', List[str]),\r
207                                  ('varargs', Optional[str]),\r
208                                  ('keywords', Optional[str]),\r
209                                  ('locals', Dict[str, Any]),\r
210                                  ])\r
211 \r
212 def getargvalues(frame: FrameType) -> ArgInfo: ...\r
213 def formatannotation(annotation: object, base_module: Optional[str] = ...) -> str: ...\r
214 def formatannotationrelativeto(object: object) -> Callable[[object], str]: ...\r
215 def formatargspec(args: List[str],\r
216                   varargs: Optional[str] = ...,\r
217                   varkw: Optional[str] = ...,\r
218                   defaults: Optional[Tuple[Any, ...]] = ...,\r
219                   kwonlyargs: Optional[List[str]] = ...,\r
220                   kwonlydefaults: Optional[Dict[str, Any]] = ...,\r
221                   annotations: Dict[str, Any] = ...,\r
222                   formatarg: Callable[[str], str] = ...,\r
223                   formatvarargs: Callable[[str], str] = ...,\r
224                   formatvarkw: Callable[[str], str] = ...,\r
225                   formatvalue: Callable[[Any], str] = ...,\r
226                   formatreturns: Callable[[Any], str] = ...,\r
227                   formatannotations: Callable[[Any], str] = ...,\r
228                   ) -> str: ...\r
229 def formatargvalues(args: List[str],\r
230                     varargs: Optional[str] = ...,\r
231                     varkw: Optional[str] = ...,\r
232                     locals: Optional[Dict[str, Any]] = ...,\r
233                     formatarg: Optional[Callable[[str], str]] = ...,\r
234                     formatvarargs: Optional[Callable[[str], str]] = ...,\r
235                     formatvarkw: Optional[Callable[[str], str]] = ...,\r
236                     formatvalue: Optional[Callable[[Any], str]] = ...,\r
237                     ) -> str: ...\r
238 def getmro(cls: type) -> Tuple[type, ...]: ...\r
239 \r
240 def getcallargs(func: Callable[..., Any],\r
241                 *args: Any,\r
242                 **kwds: Any) -> Dict[str, Any]: ...\r
243 \r
244 \r
245 ClosureVars = NamedTuple('ClosureVars', [('nonlocals', Mapping[str, Any]),\r
246                                          ('globals', Mapping[str, Any]),\r
247                                          ('builtins', Mapping[str, Any]),\r
248                                          ('unbound', AbstractSet[str]),\r
249                                          ])\r
250 def getclosurevars(func: Callable[..., Any]) -> ClosureVars: ...\r
251 \r
252 def unwrap(func: Callable[..., Any],\r
253            *,\r
254            stop: Callable[[Any], Any]) -> Any: ...\r
255 \r
256 \r
257 #\r
258 # The interpreter stack\r
259 #\r
260 \r
261 Traceback = NamedTuple(\r
262     'Traceback',\r
263     [\r
264         ('filename', str),\r
265         ('lineno', int),\r
266         ('function', str),\r
267         ('code_context', List[str]),\r
268         ('index', int),\r
269     ]\r
270 )\r
271 \r
272 # Python 3.5+ (functions returning it used to return regular tuples)\r
273 FrameInfo = NamedTuple('FrameInfo', [('frame', FrameType),\r
274                                      ('filename', str),\r
275                                      ('lineno', int),\r
276                                      ('function', str),\r
277                                      ('code_context', List[str]),\r
278                                      ('index', int),\r
279                                      ])\r
280 \r
281 def getframeinfo(frame: Union[FrameType, TracebackType], context: int = ...) -> Traceback: ...\r
282 def getouterframes(frame: Any, context: int = ...) -> List[FrameInfo]: ...\r
283 def getinnerframes(traceback: TracebackType, context: int = ...) -> List[FrameInfo]: ...\r
284 def getlineno(frame: FrameType) -> int: ...\r
285 def currentframe() -> Optional[FrameType]: ...\r
286 def stack(context: int = ...) -> List[FrameInfo]: ...\r
287 def trace(context: int = ...) -> List[FrameInfo]: ...\r
288 \r
289 #\r
290 # Fetching attributes statically\r
291 #\r
292 \r
293 def getattr_static(obj: object, attr: str, default: Optional[Any] = ...) -> Any: ...\r
294 \r
295 \r
296 #\r
297 # Current State of Generators and Coroutines\r
298 #\r
299 \r
300 # TODO In the next two blocks of code, can we be more specific regarding the\r
301 # type of the "enums"?\r
302 \r
303 GEN_CREATED: str\r
304 GEN_RUNNING: str\r
305 GEN_SUSPENDED: str\r
306 GEN_CLOSED: str\r
307 def getgeneratorstate(generator: Generator[Any, Any, Any]) -> str: ...\r
308 \r
309 if sys.version_info >= (3, 5):\r
310     CORO_CREATED: str\r
311     CORO_RUNNING: str\r
312     CORO_SUSPENDED: str\r
313     CORO_CLOSED: str\r
314     # TODO can we be more specific than "object"?\r
315     def getcoroutinestate(coroutine: object) -> str: ...\r
316 \r
317 def getgeneratorlocals(generator: Generator[Any, Any, Any]) -> Dict[str, Any]: ...\r
318 \r
319 if sys.version_info >= (3, 5):\r
320     # TODO can we be more specific than "object"?\r
321     def getcoroutinelocals(coroutine: object) -> Dict[str, Any]: ...\r
322 \r
323 Attribute = NamedTuple('Attribute', [('name', str),\r
324                                      ('kind', str),\r
325                                      ('defining_class', type),\r
326                                      ('object', object),\r
327                                      ])\r
328 \r
329 def classify_class_attrs(cls: type) -> List[Attribute]: ...\r