massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / coc-python-data / languageServer.0.5.59 / Typeshed / stdlib / 3 / typing.pyi
1 # Stubs for typing\r
2 \r
3 import sys\r
4 from abc import abstractmethod, ABCMeta\r
5 from types import CodeType, FrameType, TracebackType\r
6 import collections  # Needed by aliases like DefaultDict, see mypy issue 2986\r
7 \r
8 # Definitions of special type checking related constructs.  Their definition\r
9 # are not used, so their value does not matter.\r
10 \r
11 overload = object()\r
12 Any = object()\r
13 TypeVar = object()\r
14 _promote = object()\r
15 no_type_check = object()\r
16 \r
17 class _SpecialForm:\r
18     def __getitem__(self, typeargs: Any) -> Any: ...\r
19 \r
20 Tuple: _SpecialForm = ...\r
21 Generic: _SpecialForm = ...\r
22 Protocol: _SpecialForm = ...\r
23 Callable: _SpecialForm = ...\r
24 Type: _SpecialForm = ...\r
25 ClassVar: _SpecialForm = ...\r
26 \r
27 class GenericMeta(type): ...\r
28 \r
29 # Return type that indicates a function does not return.\r
30 # This type is equivalent to the None type, but the no-op Union is necessary to\r
31 # distinguish the None type from the None value.\r
32 NoReturn = Union[None]\r
33 \r
34 # Type aliases and type constructors\r
35 \r
36 class TypeAlias:\r
37     # Class for defining generic aliases for library types.\r
38     def __init__(self, target_type: type) -> None: ...\r
39     def __getitem__(self, typeargs: Any) -> Any: ...\r
40 \r
41 Union = TypeAlias(object)\r
42 Optional = TypeAlias(object)\r
43 List = TypeAlias(object)\r
44 Dict = TypeAlias(object)\r
45 DefaultDict = TypeAlias(object)\r
46 Set = TypeAlias(object)\r
47 FrozenSet = TypeAlias(object)\r
48 Counter = TypeAlias(object)\r
49 Deque = TypeAlias(object)\r
50 ChainMap = TypeAlias(object)\r
51 \r
52 # Predefined type variables.\r
53 AnyStr = TypeVar('AnyStr', str, bytes)\r
54 \r
55 # Abstract base classes.\r
56 \r
57 # These type variables are used by the container types.\r
58 _T = TypeVar('_T')\r
59 _S = TypeVar('_S')\r
60 _KT = TypeVar('_KT')  # Key type.\r
61 _VT = TypeVar('_VT')  # Value type.\r
62 _T_co = TypeVar('_T_co', covariant=True)  # Any type covariant containers.\r
63 _V_co = TypeVar('_V_co', covariant=True)  # Any type covariant containers.\r
64 _KT_co = TypeVar('_KT_co', covariant=True)  # Key type covariant containers.\r
65 _VT_co = TypeVar('_VT_co', covariant=True)  # Value type covariant containers.\r
66 _T_contra = TypeVar('_T_contra', contravariant=True)  # Ditto contravariant.\r
67 _TC = TypeVar('_TC', bound=Type[object])\r
68 \r
69 def runtime(cls: _TC) -> _TC: ...\r
70 \r
71 @runtime\r
72 class SupportsInt(Protocol, metaclass=ABCMeta):\r
73     @abstractmethod\r
74     def __int__(self) -> int: ...\r
75 \r
76 @runtime\r
77 class SupportsFloat(Protocol, metaclass=ABCMeta):\r
78     @abstractmethod\r
79     def __float__(self) -> float: ...\r
80 \r
81 @runtime\r
82 class SupportsComplex(Protocol, metaclass=ABCMeta):\r
83     @abstractmethod\r
84     def __complex__(self) -> complex: ...\r
85 \r
86 @runtime\r
87 class SupportsBytes(Protocol, metaclass=ABCMeta):\r
88     @abstractmethod\r
89     def __bytes__(self) -> bytes: ...\r
90 \r
91 @runtime\r
92 class SupportsAbs(Protocol[_T_co]):\r
93     @abstractmethod\r
94     def __abs__(self) -> _T_co: ...\r
95 \r
96 @runtime\r
97 class SupportsRound(Protocol[_T_co]):\r
98     @abstractmethod\r
99     def __round__(self, ndigits: int = ...) -> _T_co: ...\r
100 \r
101 @runtime\r
102 class Reversible(Protocol[_T_co]):\r
103     @abstractmethod\r
104     def __reversed__(self) -> Iterator[_T_co]: ...\r
105 \r
106 @runtime\r
107 class Sized(Protocol, metaclass=ABCMeta):\r
108     @abstractmethod\r
109     def __len__(self) -> int: ...\r
110 \r
111 @runtime\r
112 class Hashable(Protocol, metaclass=ABCMeta):\r
113     # TODO: This is special, in that a subclass of a hashable class may not be hashable\r
114     #   (for example, list vs. object). It's not obvious how to represent this. This class\r
115     #   is currently mostly useless for static checking.\r
116     @abstractmethod\r
117     def __hash__(self) -> int: ...\r
118 \r
119 @runtime\r
120 class Iterable(Protocol[_T_co]):\r
121     @abstractmethod\r
122     def __iter__(self) -> Iterator[_T_co]: ...\r
123 \r
124 @runtime\r
125 class Iterator(Iterable[_T_co], Protocol[_T_co]):\r
126     @abstractmethod\r
127     def __next__(self) -> _T_co: ...\r
128     def __iter__(self) -> Iterator[_T_co]: ...\r
129 \r
130 class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):\r
131     @abstractmethod\r
132     def __next__(self) -> _T_co: ...\r
133 \r
134     @abstractmethod\r
135     def send(self, value: _T_contra) -> _T_co: ...\r
136 \r
137     @abstractmethod\r
138     def throw(self, typ: Type[BaseException], val: Optional[BaseException] = ...,\r
139               tb: Optional[TracebackType] = ...) -> _T_co: ...\r
140 \r
141     @abstractmethod\r
142     def close(self) -> None: ...\r
143 \r
144     @abstractmethod\r
145     def __iter__(self) -> Generator[_T_co, _T_contra, _V_co]: ...\r
146 \r
147     @property\r
148     def gi_code(self) -> CodeType: ...\r
149     @property\r
150     def gi_frame(self) -> FrameType: ...\r
151     @property\r
152     def gi_running(self) -> bool: ...\r
153     @property\r
154     def gi_yieldfrom(self) -> Optional[Generator]: ...\r
155 \r
156 # TODO: Several types should only be defined if sys.python_version >= (3, 5):\r
157 # Awaitable, AsyncIterator, AsyncIterable, Coroutine, Collection.\r
158 # See https: //github.com/python/typeshed/issues/655 for why this is not easy.\r
159 \r
160 @runtime\r
161 class Awaitable(Protocol[_T_co]):\r
162     @abstractmethod\r
163     def __await__(self) -> Generator[Any, None, _T_co]: ...\r
164 \r
165 class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]):\r
166     @abstractmethod\r
167     def send(self, value: _T_contra) -> _T_co: ...\r
168 \r
169     @abstractmethod\r
170     def throw(self, typ: Type[BaseException], val: Optional[BaseException] = ...,\r
171               tb: Optional[TracebackType] = ...) -> _T_co: ...\r
172 \r
173     @abstractmethod\r
174     def close(self) -> None: ...\r
175 \r
176 \r
177 # NOTE: This type does not exist in typing.py or PEP 484.\r
178 # The parameters corrrespond to Generator, but the 4th is the original type.\r
179 class AwaitableGenerator(Awaitable[_V_co], Generator[_T_co, _T_contra, _V_co],\r
180                          Generic[_T_co, _T_contra, _V_co, _S], metaclass=ABCMeta): ...\r
181 \r
182 @runtime\r
183 class AsyncIterable(Protocol[_T_co]):\r
184     @abstractmethod\r
185     def __aiter__(self) -> AsyncIterator[_T_co]: ...\r
186 \r
187 @runtime\r
188 class AsyncIterator(AsyncIterable[_T_co],\r
189                     Protocol[_T_co]):\r
190     @abstractmethod\r
191     def __anext__(self) -> Awaitable[_T_co]: ...\r
192     def __aiter__(self) -> AsyncIterator[_T_co]: ...\r
193 \r
194 if sys.version_info >= (3, 6):\r
195     class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]):\r
196         @abstractmethod\r
197         def __anext__(self) -> Awaitable[_T_co]: ...\r
198 \r
199         @abstractmethod\r
200         def asend(self, value: _T_contra) -> Awaitable[_T_co]: ...\r
201 \r
202         @abstractmethod\r
203         def athrow(self, typ: Type[BaseException], val: Optional[BaseException] = ...,\r
204                    tb: Any = ...) -> Awaitable[_T_co]: ...\r
205 \r
206         @abstractmethod\r
207         def aclose(self) -> Awaitable[_T_co]: ...\r
208 \r
209         @abstractmethod\r
210         def __aiter__(self) -> AsyncGenerator[_T_co, _T_contra]: ...\r
211 \r
212         @property\r
213         def ag_await(self) -> Any: ...\r
214         @property\r
215         def ag_code(self) -> CodeType: ...\r
216         @property\r
217         def ag_frame(self) -> FrameType: ...\r
218         @property\r
219         def ag_running(self) -> bool: ...\r
220 \r
221 @runtime\r
222 class Container(Protocol[_T_co]):\r
223     @abstractmethod\r
224     def __contains__(self, x: object) -> bool: ...\r
225 \r
226 \r
227 if sys.version_info >= (3, 6):\r
228     @runtime\r
229     class Collection(Sized, Iterable[_T_co], Container[_T_co], Protocol[_T_co]): ...\r
230     _Collection = Collection\r
231 else:\r
232     @runtime\r
233     class _Collection(Sized, Iterable[_T_co], Container[_T_co], Protocol[_T_co]): ...\r
234 \r
235 class Sequence(_Collection[_T_co], Reversible[_T_co], Generic[_T_co]):\r
236     @overload\r
237     @abstractmethod\r
238     def __getitem__(self, i: int) -> _T_co: ...\r
239     @overload\r
240     @abstractmethod\r
241     def __getitem__(self, s: slice) -> Sequence[_T_co]: ...\r
242     # Mixin methods\r
243     if sys.version_info >= (3, 5):\r
244         def index(self, x: Any, start: int = ..., end: int = ...) -> int: ...\r
245     else:\r
246         def index(self, x: Any) -> int: ...\r
247     def count(self, x: Any) -> int: ...\r
248     def __contains__(self, x: object) -> bool: ...\r
249     def __iter__(self) -> Iterator[_T_co]: ...\r
250     def __reversed__(self) -> Iterator[_T_co]: ...\r
251 \r
252 class MutableSequence(Sequence[_T], Generic[_T]):\r
253     @abstractmethod\r
254     def insert(self, index: int, object: _T) -> None: ...\r
255     @overload\r
256     @abstractmethod\r
257     def __setitem__(self, i: int, o: _T) -> None: ...\r
258     @overload\r
259     @abstractmethod\r
260     def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ...\r
261     @overload\r
262     @abstractmethod\r
263     def __delitem__(self, i: int) -> None: ...\r
264     @overload\r
265     @abstractmethod\r
266     def __delitem__(self, i: slice) -> None: ...\r
267     # Mixin methods\r
268     def append(self, object: _T) -> None: ...\r
269     def clear(self) -> None: ...\r
270     def extend(self, iterable: Iterable[_T]) -> None: ...\r
271     def reverse(self) -> None: ...\r
272     def pop(self, index: int = ...) -> _T: ...\r
273     def remove(self, object: _T) -> None: ...\r
274     def __iadd__(self, x: Iterable[_T]) -> MutableSequence[_T]: ...\r
275 \r
276 class AbstractSet(_Collection[_T_co], Generic[_T_co]):\r
277     @abstractmethod\r
278     def __contains__(self, x: object) -> bool: ...\r
279     # Mixin methods\r
280     def __le__(self, s: AbstractSet[Any]) -> bool: ...\r
281     def __lt__(self, s: AbstractSet[Any]) -> bool: ...\r
282     def __gt__(self, s: AbstractSet[Any]) -> bool: ...\r
283     def __ge__(self, s: AbstractSet[Any]) -> bool: ...\r
284     def __and__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ...\r
285     def __or__(self, s: AbstractSet[_T]) -> AbstractSet[Union[_T_co, _T]]: ...\r
286     def __sub__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ...\r
287     def __xor__(self, s: AbstractSet[_T]) -> AbstractSet[Union[_T_co, _T]]: ...\r
288     # TODO: Argument can be a more general ABC?\r
289     def isdisjoint(self, s: AbstractSet[Any]) -> bool: ...\r
290 \r
291 class MutableSet(AbstractSet[_T], Generic[_T]):\r
292     @abstractmethod\r
293     def add(self, x: _T) -> None: ...\r
294     @abstractmethod\r
295     def discard(self, x: _T) -> None: ...\r
296     # Mixin methods\r
297     def clear(self) -> None: ...\r
298     def pop(self) -> _T: ...\r
299     def remove(self, element: _T) -> None: ...\r
300     def __ior__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ...\r
301     def __iand__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ...\r
302     def __ixor__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ...\r
303     def __isub__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ...\r
304 \r
305 class MappingView(Sized):\r
306     def __len__(self) -> int: ...\r
307 \r
308 class ItemsView(AbstractSet[Tuple[_KT_co, _VT_co]], MappingView, Generic[_KT_co, _VT_co]):\r
309     def __contains__(self, o: object) -> bool: ...\r
310     def __iter__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ...\r
311 \r
312 class KeysView(AbstractSet[_KT_co], MappingView, Generic[_KT_co]):\r
313     def __contains__(self, o: object) -> bool: ...\r
314     def __iter__(self) -> Iterator[_KT_co]: ...\r
315 \r
316 class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]):\r
317     def __contains__(self, o: object) -> bool: ...\r
318     def __iter__(self) -> Iterator[_VT_co]: ...\r
319 \r
320 @runtime\r
321 class ContextManager(Protocol[_T_co]):\r
322     def __enter__(self) -> _T_co: ...\r
323     def __exit__(self, exc_type: Optional[Type[BaseException]],\r
324                  exc_value: Optional[BaseException],\r
325                  traceback: Optional[TracebackType]) -> Optional[bool]: ...\r
326 \r
327 if sys.version_info >= (3, 5):\r
328     @runtime\r
329     class AsyncContextManager(Protocol[_T_co]):\r
330         def __aenter__(self) -> Awaitable[_T_co]: ...\r
331         def __aexit__(self, exc_type: Optional[Type[BaseException]],\r
332                       exc_value: Optional[BaseException],\r
333                       traceback: Optional[TracebackType]) -> Awaitable[Optional[bool]]: ...\r
334 \r
335 class Mapping(_Collection[_KT], Generic[_KT, _VT_co]):\r
336     # TODO: We wish the key type could also be covariant, but that doesn't work,\r
337     # see discussion in https: //github.com/python/typing/pull/273.\r
338     @abstractmethod\r
339     def __getitem__(self, k: _KT) -> _VT_co:\r
340         ...\r
341     # Mixin methods\r
342     @overload\r
343     def get(self, k: _KT) -> Optional[_VT_co]: ...\r
344     @overload\r
345     def get(self, k: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]: ...\r
346     def items(self) -> AbstractSet[Tuple[_KT, _VT_co]]: ...\r
347     def keys(self) -> AbstractSet[_KT]: ...\r
348     def values(self) -> ValuesView[_VT_co]: ...\r
349     def __contains__(self, o: object) -> bool: ...\r
350 \r
351 class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]):\r
352     @abstractmethod\r
353     def __setitem__(self, k: _KT, v: _VT) -> None: ...\r
354     @abstractmethod\r
355     def __delitem__(self, v: _KT) -> None: ...\r
356 \r
357     def clear(self) -> None: ...\r
358     @overload\r
359     def pop(self, k: _KT) -> _VT: ...\r
360     @overload\r
361     def pop(self, k: _KT, default: Union[_VT, _T] = ...) -> Union[_VT, _T]: ...\r
362     def popitem(self) -> Tuple[_KT, _VT]: ...\r
363     def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ...\r
364     # 'update' used to take a Union, but using overloading is better.\r
365     # The second overloaded type here is a bit too general, because\r
366     # Mapping[Tuple[_KT, _VT], W] is a subclass of Iterable[Tuple[_KT, _VT]],\r
367     # but will always have the behavior of the first overloaded type\r
368     # at runtime, leading to keys of a mix of types _KT and Tuple[_KT, _VT].\r
369     # We don't currently have any way of forcing all Mappings to use\r
370     # the first overload, but by using overloading rather than a Union,\r
371     # mypy will commit to using the first overload when the argument is\r
372     # known to be a Mapping with unknown type parameters, which is closer\r
373     # to the behavior we want. See mypy issue  #1430.\r
374     @overload\r
375     def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...\r
376     @overload\r
377     def update(self, __m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...\r
378     @overload\r
379     def update(self, **kwargs: _VT) -> None: ...\r
380 \r
381 Text = str\r
382 \r
383 TYPE_CHECKING = True\r
384 \r
385 class IO(Iterator[AnyStr], Generic[AnyStr]):\r
386     # TODO detach\r
387     # TODO use abstract properties\r
388     @property\r
389     def mode(self) -> str: ...\r
390     @property\r
391     def name(self) -> str: ...\r
392     @abstractmethod\r
393     def close(self) -> None: ...\r
394     @property\r
395     def closed(self) -> bool: ...\r
396     @abstractmethod\r
397     def fileno(self) -> int: ...\r
398     @abstractmethod\r
399     def flush(self) -> None: ...\r
400     @abstractmethod\r
401     def isatty(self) -> bool: ...\r
402     # TODO what if n is None?\r
403     @abstractmethod\r
404     def read(self, n: int = ...) -> AnyStr: ...\r
405     @abstractmethod\r
406     def readable(self) -> bool: ...\r
407     @abstractmethod\r
408     def readline(self, limit: int = ...) -> AnyStr: ...\r
409     @abstractmethod\r
410     def readlines(self, hint: int = ...) -> list[AnyStr]: ...\r
411     @abstractmethod\r
412     def seek(self, offset: int, whence: int = ...) -> int: ...\r
413     @abstractmethod\r
414     def seekable(self) -> bool: ...\r
415     @abstractmethod\r
416     def tell(self) -> int: ...\r
417     @abstractmethod\r
418     def truncate(self, size: Optional[int] = ...) -> int: ...\r
419     @abstractmethod\r
420     def writable(self) -> bool: ...\r
421     # TODO buffer objects\r
422     @abstractmethod\r
423     def write(self, s: AnyStr) -> int: ...\r
424     @abstractmethod\r
425     def writelines(self, lines: Iterable[AnyStr]) -> None: ...\r
426 \r
427     @abstractmethod\r
428     def __next__(self) -> AnyStr: ...\r
429     @abstractmethod\r
430     def __iter__(self) -> Iterator[AnyStr]: ...\r
431     @abstractmethod\r
432     def __enter__(self) -> IO[AnyStr]: ...\r
433     @abstractmethod\r
434     def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException],\r
435                  traceback: Optional[TracebackType]) -> bool: ...\r
436 \r
437 class BinaryIO(IO[bytes]):\r
438     # TODO readinto\r
439     # TODO read1?\r
440     # TODO peek?\r
441     @overload\r
442     @abstractmethod\r
443     def write(self, s: bytearray) -> int: ...\r
444     @overload\r
445     @abstractmethod\r
446     def write(self, s: bytes) -> int: ...\r
447 \r
448     @abstractmethod\r
449     def __enter__(self) -> BinaryIO: ...\r
450 \r
451 class TextIO(IO[str]):\r
452     # TODO use abstractproperty\r
453     @property\r
454     def buffer(self) -> BinaryIO: ...\r
455     @property\r
456     def encoding(self) -> str: ...\r
457     @property\r
458     def errors(self) -> Optional[str]: ...\r
459     @property\r
460     def line_buffering(self) -> int: ...  # int on PyPy, bool on CPython\r
461     @property\r
462     def newlines(self) -> Any: ...  # None, str or tuple\r
463     @abstractmethod\r
464     def __enter__(self) -> TextIO: ...\r
465 \r
466 class ByteString(Sequence[int], metaclass=ABCMeta): ...\r
467 \r
468 class Match(Generic[AnyStr]):\r
469     pos = 0\r
470     endpos = 0\r
471     lastindex = 0\r
472     lastgroup = ...  # type: AnyStr\r
473     string = ...  # type: AnyStr\r
474 \r
475     # The regular expression object whose match() or search() method produced\r
476     # this match instance.\r
477     re = ...  # type: 'Pattern[AnyStr]'\r
478 \r
479     def expand(self, template: AnyStr) -> AnyStr: ...\r
480 \r
481     @overload\r
482     def group(self, group1: int = ...) -> AnyStr: ...\r
483     @overload\r
484     def group(self, group1: str) -> AnyStr: ...\r
485     @overload\r
486     def group(self, group1: int, group2: int,\r
487               *groups: int) -> Sequence[AnyStr]: ...\r
488     @overload\r
489     def group(self, group1: str, group2: str,\r
490               *groups: str) -> Sequence[AnyStr]: ...\r
491 \r
492     def groups(self, default: AnyStr = ...) -> Sequence[AnyStr]: ...\r
493     def groupdict(self, default: AnyStr = ...) -> dict[str, AnyStr]: ...\r
494     def start(self, group: Union[int, str] = ...) -> int: ...\r
495     def end(self, group: Union[int, str] = ...) -> int: ...\r
496     def span(self, group: Union[int, str] = ...) -> Tuple[int, int]: ...\r
497     if sys.version_info >= (3, 6):\r
498         def __getitem__(self, g: Union[int, str]) -> AnyStr: ...\r
499 \r
500 class Pattern(Generic[AnyStr]):\r
501     flags = 0\r
502     groupindex = ...  # type: Mapping[str, int]\r
503     groups = 0\r
504     pattern = ...  # type: AnyStr\r
505 \r
506     def search(self, string: AnyStr, pos: int = ...,\r
507                endpos: int = ...) -> Optional[Match[AnyStr]]: ...\r
508     def match(self, string: AnyStr, pos: int = ...,\r
509               endpos: int = ...) -> Optional[Match[AnyStr]]: ...\r
510     # New in Python 3.4\r
511     def fullmatch(self, string: AnyStr, pos: int = ...,\r
512                   endpos: int = ...) -> Optional[Match[AnyStr]]: ...\r
513     def split(self, string: AnyStr, maxsplit: int = ...) -> list[AnyStr]: ...\r
514     def findall(self, string: AnyStr, pos: int = ...,\r
515                 endpos: int = ...) -> list[Any]: ...\r
516     def finditer(self, string: AnyStr, pos: int = ...,\r
517                  endpos: int = ...) -> Iterator[Match[AnyStr]]: ...\r
518 \r
519     @overload\r
520     def sub(self, repl: AnyStr, string: AnyStr,\r
521             count: int = ...) -> AnyStr: ...\r
522     @overload\r
523     def sub(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr,\r
524             count: int = ...) -> AnyStr: ...\r
525 \r
526     @overload\r
527     def subn(self, repl: AnyStr, string: AnyStr,\r
528              count: int = ...) -> Tuple[AnyStr, int]: ...\r
529     @overload\r
530     def subn(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr,\r
531              count: int = ...) -> Tuple[AnyStr, int]: ...\r
532 \r
533 # Functions\r
534 \r
535 def get_type_hints(obj: Callable, globalns: Optional[dict[str, Any]] = ...,\r
536                    localns: Optional[dict[str, Any]] = ...) -> dict[str, Any]: ...\r
537 \r
538 def cast(tp: Type[_T], obj: Any) -> _T: ...\r
539 \r
540 # Type constructors\r
541 \r
542 # NamedTuple is special-cased in the type checker\r
543 class NamedTuple(tuple):\r
544     _field_types = ...  # type: collections.OrderedDict[str, Type[Any]]\r
545     _fields = ...  # type: Tuple[str, ...]\r
546     _source = ...  # type: str\r
547 \r
548     def __init__(self, typename: str, fields: Iterable[Tuple[str, Any]] = ..., *,\r
549                  verbose: bool = ..., rename: bool = ..., **kwargs: Any) -> None: ...\r
550 \r
551     @classmethod\r
552     def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ...\r
553 \r
554     def _asdict(self) -> collections.OrderedDict[str, Any]: ...\r
555     def _replace(self: _T, **kwargs: Any) -> _T: ...\r
556 \r
557 def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...\r