Debian Codegraph @

jedi/third_party/typeshed/stdlib/types.pyi

raw symbols SCIP
1 import sys
2 from _typeshed import AnnotationForm, MaybeNone, SupportsKeysAndGetItem
3 from _typeshed.importlib import LoaderProtocol
4 from collections.abc import (
5 AsyncGenerator,
6 Awaitable,
7 Callable,
8 Coroutine,
9 Generator,
10 ItemsView,
11 Iterable,
12 Iterator,
13 KeysView,
14 Mapping,
15 MutableSequence,
16 ValuesView,
17 )
18 from importlib.machinery import ModuleSpec
19 from typing import Any, ClassVar, Literal, TypeVar, final, overload
20 from typing_extensions import ParamSpec, Self, TypeAliasType, TypeVarTuple, deprecated, disjoint_base
21
22 if sys.version_info >= (3, 14):
23 from _typeshed import AnnotateFunc
24
25 __all__ = [
26 "FunctionType",
27 "LambdaType",
28 "CodeType",
29 "MappingProxyType",
30 "SimpleNamespace",
31 "GeneratorType",
32 "CoroutineType",
33 "AsyncGeneratorType",
34 "MethodType",
35 "BuiltinFunctionType",
36 "ModuleType",
37 "TracebackType",
38 "FrameType",
39 "GetSetDescriptorType",
40 "MemberDescriptorType",
41 "new_class",
42 "prepare_class",
43 "DynamicClassAttribute",
44 "coroutine",
45 "BuiltinMethodType",
46 "ClassMethodDescriptorType",
47 "MethodDescriptorType",
48 "MethodWrapperType",
49 "WrapperDescriptorType",
50 "resolve_bases",
51 "CellType",
52 "GenericAlias",
53 ]
54
55 if sys.version_info >= (3, 10):
56 __all__ += ["EllipsisType", "NoneType", "NotImplementedType", "UnionType"]
57
58 if sys.version_info >= (3, 12):
59 __all__ += ["get_original_bases"]
60
61 if sys.version_info >= (3, 13):
62 __all__ += ["CapsuleType"]
63
64 # Note, all classes "defined" here require special handling.
65
66 _T1 = TypeVar("_T1")
67 _T2 = TypeVar("_T2")
68 _KT_co = TypeVar("_KT_co", covariant=True)
69 _VT_co = TypeVar("_VT_co", covariant=True)
70
71 # Make sure this class definition stays roughly in line with `builtins.function`
72 @final
73 class FunctionType:
74 @property
75 def __closure__(self) -> tuple[CellType, ...] | None: ...
76 __code__: CodeType
77 __defaults__: tuple[Any, ...] | None
78 __dict__: dict[str, Any]
79 @property
80 def __globals__(self) -> dict[str, Any]: ...
81 __name__: str
82 __qualname__: str
83 __annotations__: dict[str, AnnotationForm]
84 if sys.version_info >= (3, 14):
85 __annotate__: AnnotateFunc | None
86 __kwdefaults__: dict[str, Any] | None
87 if sys.version_info >= (3, 10):
88 @property
89 def __builtins__(self) -> dict[str, Any]: ...
90 if sys.version_info >= (3, 12):
91 __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...]
92
93 __module__: str
94 if sys.version_info >= (3, 13):
95 def __new__(
96 cls,
97 code: CodeType,
98 globals: dict[str, Any],
99 name: str | None = None,
100 argdefs: tuple[object, ...] | None = None,
101 closure: tuple[CellType, ...] | None = None,
102 kwdefaults: dict[str, object] | None = None,
103 ) -> Self: ...
104 else:
105 def __new__(
106 cls,
107 code: CodeType,
108 globals: dict[str, Any],
109 name: str | None = None,
110 argdefs: tuple[object, ...] | None = None,
111 closure: tuple[CellType, ...] | None = None,
112 ) -> Self: ...
113
114 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
115 @overload
116 def __get__(self, instance: None, owner: type, /) -> FunctionType: ...
117 @overload
118 def __get__(self, instance: object, owner: type | None = None, /) -> MethodType: ...
119
120 LambdaType = FunctionType
121
122 @final
123 class CodeType:
124 def __eq__(self, value: object, /) -> bool: ...
125 def __hash__(self) -> int: ...
126 @property
127 def co_argcount(self) -> int: ...
128 @property
129 def co_posonlyargcount(self) -> int: ...
130 @property
131 def co_kwonlyargcount(self) -> int: ...
132 @property
133 def co_nlocals(self) -> int: ...
134 @property
135 def co_stacksize(self) -> int: ...
136 @property
137 def co_flags(self) -> int: ...
138 @property
139 def co_code(self) -> bytes: ...
140 @property
141 def co_consts(self) -> tuple[Any, ...]: ...
142 @property
143 def co_names(self) -> tuple[str, ...]: ...
144 @property
145 def co_varnames(self) -> tuple[str, ...]: ...
146 @property
147 def co_filename(self) -> str: ...
148 @property
149 def co_name(self) -> str: ...
150 @property
151 def co_firstlineno(self) -> int: ...
152 if sys.version_info >= (3, 10):
153 @property
154 @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `CodeType.co_lines()` instead.")
155 def co_lnotab(self) -> bytes: ...
156 else:
157 @property
158 def co_lnotab(self) -> bytes: ...
159
160 @property
161 def co_freevars(self) -> tuple[str, ...]: ...
162 @property
163 def co_cellvars(self) -> tuple[str, ...]: ...
164 if sys.version_info >= (3, 10):
165 @property
166 def co_linetable(self) -> bytes: ...
167 def co_lines(self) -> Iterator[tuple[int, int, int | None]]: ...
168 if sys.version_info >= (3, 11):
169 @property
170 def co_exceptiontable(self) -> bytes: ...
171 @property
172 def co_qualname(self) -> str: ...
173 def co_positions(self) -> Iterable[tuple[int | None, int | None, int | None, int | None]]: ...
174 if sys.version_info >= (3, 14):
175 def co_branches(self) -> Iterator[tuple[int, int, int]]: ...
176
177 if sys.version_info >= (3, 11):
178 def __new__(
179 cls,
180 argcount: int,
181 posonlyargcount: int,
182 kwonlyargcount: int,
183 nlocals: int,
184 stacksize: int,
185 flags: int,
186 codestring: bytes,
187 constants: tuple[object, ...],
188 names: tuple[str, ...],
189 varnames: tuple[str, ...],
190 filename: str,
191 name: str,
192 qualname: str,
193 firstlineno: int,
194 linetable: bytes,
195 exceptiontable: bytes,
196 freevars: tuple[str, ...] = ...,
197 cellvars: tuple[str, ...] = ...,
198 /,
199 ) -> Self: ...
200 elif sys.version_info >= (3, 10):
201 def __new__(
202 cls,
203 argcount: int,
204 posonlyargcount: int,
205 kwonlyargcount: int,
206 nlocals: int,
207 stacksize: int,
208 flags: int,
209 codestring: bytes,
210 constants: tuple[object, ...],
211 names: tuple[str, ...],
212 varnames: tuple[str, ...],
213 filename: str,
214 name: str,
215 firstlineno: int,
216 linetable: bytes,
217 freevars: tuple[str, ...] = ...,
218 cellvars: tuple[str, ...] = ...,
219 /,
220 ) -> Self: ...
221 else:
222 def __new__(
223 cls,
224 argcount: int,
225 posonlyargcount: int,
226 kwonlyargcount: int,
227 nlocals: int,
228 stacksize: int,
229 flags: int,
230 codestring: bytes,
231 constants: tuple[object, ...],
232 names: tuple[str, ...],
233 varnames: tuple[str, ...],
234 filename: str,
235 name: str,
236 firstlineno: int,
237 lnotab: bytes,
238 freevars: tuple[str, ...] = ...,
239 cellvars: tuple[str, ...] = ...,
240 /,
241 ) -> Self: ...
242 if sys.version_info >= (3, 11):
243 def replace(
244 self,
245 *,
246 co_argcount: int = -1,
247 co_posonlyargcount: int = -1,
248 co_kwonlyargcount: int = -1,
249 co_nlocals: int = -1,
250 co_stacksize: int = -1,
251 co_flags: int = -1,
252 co_firstlineno: int = -1,
253 co_code: bytes = ...,
254 co_consts: tuple[object, ...] = ...,
255 co_names: tuple[str, ...] = ...,
256 co_varnames: tuple[str, ...] = ...,
257 co_freevars: tuple[str, ...] = ...,
258 co_cellvars: tuple[str, ...] = ...,
259 co_filename: str = ...,
260 co_name: str = ...,
261 co_qualname: str = ...,
262 co_linetable: bytes = ...,
263 co_exceptiontable: bytes = ...,
264 ) -> Self: ...
265 elif sys.version_info >= (3, 10):
266 def replace(
267 self,
268 *,
269 co_argcount: int = -1,
270 co_posonlyargcount: int = -1,
271 co_kwonlyargcount: int = -1,
272 co_nlocals: int = -1,
273 co_stacksize: int = -1,
274 co_flags: int = -1,
275 co_firstlineno: int = -1,
276 co_code: bytes = ...,
277 co_consts: tuple[object, ...] = ...,
278 co_names: tuple[str, ...] = ...,
279 co_varnames: tuple[str, ...] = ...,
280 co_freevars: tuple[str, ...] = ...,
281 co_cellvars: tuple[str, ...] = ...,
282 co_filename: str = ...,
283 co_name: str = ...,
284 co_linetable: bytes = ...,
285 ) -> Self: ...
286 else:
287 def replace(
288 self,
289 *,
290 co_argcount: int = -1,
291 co_posonlyargcount: int = -1,
292 co_kwonlyargcount: int = -1,
293 co_nlocals: int = -1,
294 co_stacksize: int = -1,
295 co_flags: int = -1,
296 co_firstlineno: int = -1,
297 co_code: bytes = ...,
298 co_consts: tuple[object, ...] = ...,
299 co_names: tuple[str, ...] = ...,
300 co_varnames: tuple[str, ...] = ...,
301 co_freevars: tuple[str, ...] = ...,
302 co_cellvars: tuple[str, ...] = ...,
303 co_filename: str = ...,
304 co_name: str = ...,
305 co_lnotab: bytes = ...,
306 ) -> Self: ...
307
308 if sys.version_info >= (3, 13):
309 __replace__ = replace
310
311 @final
312 class MappingProxyType(Mapping[_KT_co, _VT_co]): # type: ignore[type-var] # pyright: ignore[reportInvalidTypeArguments]
313 __hash__: ClassVar[None] # type: ignore[assignment]
314 def __new__(cls, mapping: SupportsKeysAndGetItem[_KT_co, _VT_co]) -> Self: ...
315 def __getitem__(self, key: _KT_co, /) -> _VT_co: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
316 def __iter__(self) -> Iterator[_KT_co]: ...
317 def __len__(self) -> int: ...
318 def __eq__(self, value: object, /) -> bool: ...
319 def copy(self) -> dict[_KT_co, _VT_co]: ...
320 def keys(self) -> KeysView[_KT_co]: ...
321 def values(self) -> ValuesView[_VT_co]: ...
322 def items(self) -> ItemsView[_KT_co, _VT_co]: ...
323 @overload
324 def get(self, key: _KT_co, /) -> _VT_co | None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter
325 @overload
326 def get(self, key: _KT_co, default: _VT_co, /) -> _VT_co: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter
327 @overload
328 def get(self, key: _KT_co, default: _T2, /) -> _VT_co | _T2: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter
329 def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
330 def __reversed__(self) -> Iterator[_KT_co]: ...
331 def __or__(self, value: Mapping[_T1, _T2], /) -> dict[_KT_co | _T1, _VT_co | _T2]: ...
332 def __ror__(self, value: Mapping[_T1, _T2], /) -> dict[_KT_co | _T1, _VT_co | _T2]: ...
333
334 if sys.version_info >= (3, 12):
335 @disjoint_base
336 class SimpleNamespace:
337 __hash__: ClassVar[None] # type: ignore[assignment]
338 if sys.version_info >= (3, 13):
339 def __init__(
340 self, mapping_or_iterable: Mapping[str, Any] | Iterable[tuple[str, Any]] = (), /, **kwargs: Any
341 ) -> None: ...
342 else:
343 def __init__(self, **kwargs: Any) -> None: ...
344
345 def __eq__(self, value: object, /) -> bool: ...
346 def __getattribute__(self, name: str, /) -> Any: ...
347 def __setattr__(self, name: str, value: Any, /) -> None: ...
348 def __delattr__(self, name: str, /) -> None: ...
349 if sys.version_info >= (3, 13):
350 def __replace__(self, **kwargs: Any) -> Self: ...
351
352 else:
353 class SimpleNamespace:
354 __hash__: ClassVar[None] # type: ignore[assignment]
355 def __init__(self, **kwargs: Any) -> None: ...
356 def __eq__(self, value: object, /) -> bool: ...
357 def __getattribute__(self, name: str, /) -> Any: ...
358 def __setattr__(self, name: str, value: Any, /) -> None: ...
359 def __delattr__(self, name: str, /) -> None: ...
360
361 @disjoint_base
362 class ModuleType:
363 __name__: str
364 __file__: str | None
365 @property
366 def __dict__(self) -> dict[str, Any]: ... # type: ignore[override]
367 __loader__: LoaderProtocol | None
368 __package__: str | None
369 __path__: MutableSequence[str]
370 __spec__: ModuleSpec | None
371 # N.B. Although this is the same type as `builtins.object.__doc__`,
372 # it is deliberately redeclared here. Most symbols declared in the namespace
373 # of `types.ModuleType` are available as "implicit globals" within a module's
374 # namespace, but this is not true for symbols declared in the namespace of `builtins.object`.
375 # Redeclaring `__doc__` here helps some type checkers understand that `__doc__` is available
376 # as an implicit global in all modules, similar to `__name__`, `__file__`, `__spec__`, etc.
377 __doc__: str | None
378 __annotations__: dict[str, AnnotationForm]
379 if sys.version_info >= (3, 14):
380 __annotate__: AnnotateFunc | None
381
382 def __init__(self, name: str, doc: str | None = ...) -> None: ...
383 # __getattr__ doesn't exist at runtime,
384 # but having it here in typeshed makes dynamic imports
385 # using `builtins.__import__` or `importlib.import_module` less painful
386 def __getattr__(self, name: str) -> Any: ...
387
388 @final
389 class CellType:
390 def __new__(cls, contents: object = ..., /) -> Self: ...
391 __hash__: ClassVar[None] # type: ignore[assignment]
392 cell_contents: Any
393
394 _YieldT_co = TypeVar("_YieldT_co", covariant=True)
395 _SendT_contra = TypeVar("_SendT_contra", contravariant=True, default=None)
396 _ReturnT_co = TypeVar("_ReturnT_co", covariant=True, default=None)
397
398 @final
399 class GeneratorType(Generator[_YieldT_co, _SendT_contra, _ReturnT_co]):
400 @property
401 def gi_code(self) -> CodeType: ...
402 @property
403 def gi_frame(self) -> FrameType | None: ...
404 @property
405 def gi_running(self) -> bool: ...
406 @property
407 def gi_yieldfrom(self) -> Iterator[_YieldT_co] | None: ...
408 if sys.version_info >= (3, 11):
409 @property
410 def gi_suspended(self) -> bool: ...
411 __name__: str
412 __qualname__: str
413 def __iter__(self) -> Self: ...
414 def __next__(self) -> _YieldT_co: ...
415 def send(self, arg: _SendT_contra, /) -> _YieldT_co: ...
416 @overload
417 def throw(
418 self, typ: type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ..., /
419 ) -> _YieldT_co: ...
420 @overload
421 def throw(self, typ: BaseException, val: None = None, tb: TracebackType | None = ..., /) -> _YieldT_co: ...
422 if sys.version_info >= (3, 13):
423 def __class_getitem__(cls, item: Any, /) -> Any: ...
424
425 @final
426 class AsyncGeneratorType(AsyncGenerator[_YieldT_co, _SendT_contra]):
427 @property
428 def ag_await(self) -> Awaitable[Any] | None: ...
429 @property
430 def ag_code(self) -> CodeType: ...
431 @property
432 def ag_frame(self) -> FrameType | None: ...
433 @property
434 def ag_running(self) -> bool: ...
435 __name__: str
436 __qualname__: str
437 if sys.version_info >= (3, 12):
438 @property
439 def ag_suspended(self) -> bool: ...
440
441 def __aiter__(self) -> Self: ...
442 def __anext__(self) -> Coroutine[Any, Any, _YieldT_co]: ...
443 def asend(self, val: _SendT_contra, /) -> Coroutine[Any, Any, _YieldT_co]: ...
444 @overload
445 async def athrow(
446 self, typ: type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ..., /
447 ) -> _YieldT_co: ...
448 @overload
449 async def athrow(self, typ: BaseException, val: None = None, tb: TracebackType | None = ..., /) -> _YieldT_co: ...
450 def aclose(self) -> Coroutine[Any, Any, None]: ...
451 def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
452
453 # Non-default variations to accommodate coroutines
454 _SendT_nd_contra = TypeVar("_SendT_nd_contra", contravariant=True)
455 _ReturnT_nd_co = TypeVar("_ReturnT_nd_co", covariant=True)
456
457 @final
458 class CoroutineType(Coroutine[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co]):
459 __name__: str
460 __qualname__: str
461 @property
462 def cr_await(self) -> Any | None: ...
463 @property
464 def cr_code(self) -> CodeType: ...
465 @property
466 def cr_frame(self) -> FrameType | None: ...
467 @property
468 def cr_running(self) -> bool: ...
469 @property
470 def cr_origin(self) -> tuple[tuple[str, int, str], ...] | None: ...
471 if sys.version_info >= (3, 11):
472 @property
473 def cr_suspended(self) -> bool: ...
474
475 def close(self) -> None: ...
476 def __await__(self) -> Generator[Any, None, _ReturnT_nd_co]: ...
477 def send(self, arg: _SendT_nd_contra, /) -> _YieldT_co: ...
478 @overload
479 def throw(
480 self, typ: type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ..., /
481 ) -> _YieldT_co: ...
482 @overload
483 def throw(self, typ: BaseException, val: None = None, tb: TracebackType | None = ..., /) -> _YieldT_co: ...
484 if sys.version_info >= (3, 13):
485 def __class_getitem__(cls, item: Any, /) -> Any: ...
486
487 @final
488 class MethodType:
489 @property
490 def __closure__(self) -> tuple[CellType, ...] | None: ... # inherited from the added function
491 @property
492 def __code__(self) -> CodeType: ... # inherited from the added function
493 @property
494 def __defaults__(self) -> tuple[Any, ...] | None: ... # inherited from the added function
495 @property
496 def __func__(self) -> Callable[..., Any]: ...
497 @property
498 def __self__(self) -> object: ...
499 @property
500 def __name__(self) -> str: ... # inherited from the added function
501 @property
502 def __qualname__(self) -> str: ... # inherited from the added function
503 def __new__(cls, func: Callable[..., Any], instance: object, /) -> Self: ...
504 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
505
506 if sys.version_info >= (3, 13):
507 def __get__(self, instance: object, owner: type | None = None, /) -> Self: ...
508
509 def __eq__(self, value: object, /) -> bool: ...
510 def __hash__(self) -> int: ...
511
512 @final
513 class BuiltinFunctionType:
514 @property
515 def __self__(self) -> object | ModuleType: ...
516 @property
517 def __name__(self) -> str: ...
518 @property
519 def __qualname__(self) -> str: ...
520 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
521 def __eq__(self, value: object, /) -> bool: ...
522 def __hash__(self) -> int: ...
523
524 BuiltinMethodType = BuiltinFunctionType
525
526 @final
527 class WrapperDescriptorType:
528 @property
529 def __name__(self) -> str: ...
530 @property
531 def __qualname__(self) -> str: ...
532 @property
533 def __objclass__(self) -> type: ...
534 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
535 def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
536
537 @final
538 class MethodWrapperType:
539 @property
540 def __self__(self) -> object: ...
541 @property
542 def __name__(self) -> str: ...
543 @property
544 def __qualname__(self) -> str: ...
545 @property
546 def __objclass__(self) -> type: ...
547 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
548 def __eq__(self, value: object, /) -> bool: ...
549 def __ne__(self, value: object, /) -> bool: ...
550 def __hash__(self) -> int: ...
551
552 @final
553 class MethodDescriptorType:
554 @property
555 def __name__(self) -> str: ...
556 @property
557 def __qualname__(self) -> str: ...
558 @property
559 def __objclass__(self) -> type: ...
560 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
561 def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
562
563 @final
564 class ClassMethodDescriptorType:
565 @property
566 def __name__(self) -> str: ...
567 @property
568 def __qualname__(self) -> str: ...
569 @property
570 def __objclass__(self) -> type: ...
571 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
572 def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
573
574 @final
575 class TracebackType:
576 def __new__(cls, tb_next: TracebackType | None, tb_frame: FrameType, tb_lasti: int, tb_lineno: int) -> Self: ...
577 tb_next: TracebackType | None
578 # the rest are read-only
579 @property
580 def tb_frame(self) -> FrameType: ...
581 @property
582 def tb_lasti(self) -> int: ...
583 @property
584 def tb_lineno(self) -> int: ...
585
586 @final
587 class FrameType:
588 @property
589 def f_back(self) -> FrameType | None: ...
590 @property
591 def f_builtins(self) -> dict[str, Any]: ...
592 @property
593 def f_code(self) -> CodeType: ...
594 @property
595 def f_globals(self) -> dict[str, Any]: ...
596 @property
597 def f_lasti(self) -> int: ...
598 # see discussion in #6769: f_lineno *can* sometimes be None,
599 # but you should probably file a bug report with CPython if you encounter it being None in the wild.
600 # An `int | None` annotation here causes too many false-positive errors, so applying `int | Any`.
601 @property
602 def f_lineno(self) -> int | MaybeNone: ...
603 @property
604 def f_locals(self) -> dict[str, Any]: ...
605 f_trace: Callable[[FrameType, str, Any], Any] | None
606 f_trace_lines: bool
607 f_trace_opcodes: bool
608 def clear(self) -> None: ...
609 if sys.version_info >= (3, 14):
610 @property
611 def f_generator(self) -> GeneratorType[Any, Any, Any] | CoroutineType[Any, Any, Any] | None: ...
612
613 @final
614 class GetSetDescriptorType:
615 @property
616 def __name__(self) -> str: ...
617 @property
618 def __qualname__(self) -> str: ...
619 @property
620 def __objclass__(self) -> type: ...
621 def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
622 def __set__(self, instance: Any, value: Any, /) -> None: ...
623 def __delete__(self, instance: Any, /) -> None: ...
624
625 @final
626 class MemberDescriptorType:
627 @property
628 def __name__(self) -> str: ...
629 @property
630 def __qualname__(self) -> str: ...
631 @property
632 def __objclass__(self) -> type: ...
633 def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
634 def __set__(self, instance: Any, value: Any, /) -> None: ...
635 def __delete__(self, instance: Any, /) -> None: ...
636
637 def new_class(
638 name: str,
639 bases: Iterable[object] = (),
640 kwds: dict[str, Any] | None = None,
641 exec_body: Callable[[dict[str, Any]], object] | None = None,
642 ) -> type: ...
643 def resolve_bases(bases: Iterable[object]) -> tuple[Any, ...]: ...
644 def prepare_class(
645 name: str, bases: tuple[type, ...] = (), kwds: dict[str, Any] | None = None
646 ) -> tuple[type, dict[str, Any], dict[str, Any]]: ...
647
648 if sys.version_info >= (3, 12):
649 def get_original_bases(cls: type, /) -> tuple[Any, ...]: ...
650
651 # Does not actually inherit from property, but saying it does makes sure that
652 # pyright handles this class correctly.
653 class DynamicClassAttribute(property):
654 fget: Callable[[Any], Any] | None
655 fset: Callable[[Any, Any], object] | None # type: ignore[assignment]
656 fdel: Callable[[Any], object] | None # type: ignore[assignment]
657 overwrite_doc: bool
658 __isabstractmethod__: bool
659 def __init__(
660 self,
661 fget: Callable[[Any], Any] | None = None,
662 fset: Callable[[Any, Any], object] | None = None,
663 fdel: Callable[[Any], object] | None = None,
664 doc: str | None = None,
665 ) -> None: ...
666 def __get__(self, instance: Any, ownerclass: type | None = None) -> Any: ...
667 def __set__(self, instance: Any, value: Any) -> None: ...
668 def __delete__(self, instance: Any) -> None: ...
669 def getter(self, fget: Callable[[Any], Any]) -> DynamicClassAttribute: ...
670 def setter(self, fset: Callable[[Any, Any], object]) -> DynamicClassAttribute: ...
671 def deleter(self, fdel: Callable[[Any], object]) -> DynamicClassAttribute: ...
672
673 _Fn = TypeVar("_Fn", bound=Callable[..., object])
674 _R = TypeVar("_R")
675 _P = ParamSpec("_P")
676
677 # it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable
678 @overload
679 def coroutine(func: Callable[_P, Generator[Any, Any, _R]]) -> Callable[_P, Awaitable[_R]]: ...
680 @overload
681 def coroutine(func: _Fn) -> _Fn: ...
682 @disjoint_base
683 class GenericAlias:
684 @property
685 def __origin__(self) -> type | TypeAliasType: ...
686 @property
687 def __args__(self) -> tuple[Any, ...]: ...
688 @property
689 def __parameters__(self) -> tuple[Any, ...]: ...
690 def __new__(cls, origin: type, args: Any, /) -> Self: ...
691 def __getitem__(self, typeargs: Any, /) -> GenericAlias: ...
692 def __eq__(self, value: object, /) -> bool: ...
693 def __hash__(self) -> int: ...
694 def __mro_entries__(self, bases: Iterable[object], /) -> tuple[type, ...]: ...
695 if sys.version_info >= (3, 11):
696 @property
697 def __unpacked__(self) -> bool: ...
698 @property
699 def __typing_unpacked_tuple_args__(self) -> tuple[Any, ...] | None: ...
700 if sys.version_info >= (3, 10):
701 def __or__(self, value: Any, /) -> UnionType: ...
702 def __ror__(self, value: Any, /) -> UnionType: ...
703
704 # GenericAlias delegates attr access to `__origin__`
705 def __getattr__(self, name: str) -> Any: ...
706
707 if sys.version_info >= (3, 10):
708 @final
709 class NoneType:
710 def __bool__(self) -> Literal[False]: ...
711
712 @final
713 class EllipsisType: ...
714
715 @final
716 class NotImplementedType(Any): ...
717
718 @final
719 class UnionType:
720 @property
721 def __args__(self) -> tuple[Any, ...]: ...
722 @property
723 def __parameters__(self) -> tuple[Any, ...]: ...
724 # `(int | str) | Literal["foo"]` returns a generic alias to an instance of `_SpecialForm` (`Union`).
725 # Normally we'd express this using the return type of `_SpecialForm.__ror__`,
726 # but because `UnionType.__or__` accepts `Any`, type checkers will use
727 # the return type of `UnionType.__or__` to infer the result of this operation
728 # rather than `_SpecialForm.__ror__`. To mitigate this, we use `| Any`
729 # in the return type of `UnionType.__(r)or__`.
730 def __or__(self, value: Any, /) -> UnionType | Any: ...
731 def __ror__(self, value: Any, /) -> UnionType | Any: ...
732 def __eq__(self, value: object, /) -> bool: ...
733 def __hash__(self) -> int: ...
734 # you can only subscript a `UnionType` instance if at least one of the elements
735 # in the union is a generic alias instance that has a non-empty `__parameters__`
736 def __getitem__(self, parameters: Any, /) -> object: ...
737
738 if sys.version_info >= (3, 13):
739 @final
740 class CapsuleType: ...