Sync vendored typeshed stubs (#18110)

Close and reopen this PR to trigger CI

---------

Co-authored-by: typeshedbot <>
Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
github-actions[bot] 2025-05-14 22:14:52 -04:00 committed by GitHub
parent 466021d5e1
commit b600ff106a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
99 changed files with 2367 additions and 747 deletions

View file

@ -421,16 +421,16 @@ mod tests {
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r#" assert_snapshot!(test.goto_type_definition(), @r###"
info[goto-type-definition]: Type definition info[goto-type-definition]: Type definition
--> stdlib/builtins.pyi:438:7 --> stdlib/builtins.pyi:445:7
| |
436 | def __getitem__(self, key: int, /) -> str | int | None: ... 443 | def __getitem__(self, key: int, /) -> str | int | None: ...
437 | 444 |
438 | class str(Sequence[str]): 445 | class str(Sequence[str]):
| ^^^ | ^^^
439 | @overload 446 | @overload
440 | def __new__(cls, object: object = ...) -> Self: ... 447 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> main.py:4:13 --> main.py:4:13
@ -440,7 +440,7 @@ mod tests {
4 | a 4 | a
| ^ | ^
| |
"#); "###);
} }
#[test] #[test]
fn goto_type_of_expression_with_literal_node() { fn goto_type_of_expression_with_literal_node() {
@ -450,16 +450,16 @@ mod tests {
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r#" assert_snapshot!(test.goto_type_definition(), @r###"
info[goto-type-definition]: Type definition info[goto-type-definition]: Type definition
--> stdlib/builtins.pyi:438:7 --> stdlib/builtins.pyi:445:7
| |
436 | def __getitem__(self, key: int, /) -> str | int | None: ... 443 | def __getitem__(self, key: int, /) -> str | int | None: ...
437 | 444 |
438 | class str(Sequence[str]): 445 | class str(Sequence[str]):
| ^^^ | ^^^
439 | @overload 446 | @overload
440 | def __new__(cls, object: object = ...) -> Self: ... 447 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> main.py:2:22 --> main.py:2:22
@ -467,7 +467,7 @@ mod tests {
2 | a: str = "test" 2 | a: str = "test"
| ^^^^^^ | ^^^^^^
| |
"#); "###);
} }
#[test] #[test]
@ -532,16 +532,16 @@ mod tests {
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r#" assert_snapshot!(test.goto_type_definition(), @r###"
info[goto-type-definition]: Type definition info[goto-type-definition]: Type definition
--> stdlib/builtins.pyi:438:7 --> stdlib/builtins.pyi:445:7
| |
436 | def __getitem__(self, key: int, /) -> str | int | None: ... 443 | def __getitem__(self, key: int, /) -> str | int | None: ...
437 | 444 |
438 | class str(Sequence[str]): 445 | class str(Sequence[str]):
| ^^^ | ^^^
439 | @overload 446 | @overload
440 | def __new__(cls, object: object = ...) -> Self: ... 447 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> main.py:4:18 --> main.py:4:18
@ -551,7 +551,7 @@ mod tests {
4 | test(a= "123") 4 | test(a= "123")
| ^ | ^
| |
"#); "###);
} }
#[test] #[test]
@ -567,16 +567,16 @@ mod tests {
// TODO: This should jump to `str` and not `int` because // TODO: This should jump to `str` and not `int` because
// the keyword is typed as a string. It's only the passed argument that // the keyword is typed as a string. It's only the passed argument that
// is an int. Navigating to `str` would match pyright's behavior. // is an int. Navigating to `str` would match pyright's behavior.
assert_snapshot!(test.goto_type_definition(), @r" assert_snapshot!(test.goto_type_definition(), @r###"
info[goto-type-definition]: Type definition info[goto-type-definition]: Type definition
--> stdlib/builtins.pyi:231:7 --> stdlib/builtins.pyi:238:7
| |
229 | _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed 236 | _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
230 | 237 |
231 | class int: 238 | class int:
| ^^^ | ^^^
232 | @overload 239 | @overload
233 | def __new__(cls, x: ConvertibleToInt = ..., /) -> Self: ... 240 | def __new__(cls, x: ConvertibleToInt = ..., /) -> Self: ...
| |
info: Source info: Source
--> main.py:4:18 --> main.py:4:18
@ -586,7 +586,7 @@ mod tests {
4 | test(a= 123) 4 | test(a= 123)
| ^ | ^
| |
"); "###);
} }
#[test] #[test]
@ -601,16 +601,16 @@ f(**kwargs<CURSOR>)
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r#" assert_snapshot!(test.goto_type_definition(), @r###"
info[goto-type-definition]: Type definition info[goto-type-definition]: Type definition
--> stdlib/builtins.pyi:1086:7 --> stdlib/builtins.pyi:1096:7
| |
1084 | def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... 1094 | def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
1085 | 1095 |
1086 | class dict(MutableMapping[_KT, _VT]): 1096 | class dict(MutableMapping[_KT, _VT]):
| ^^^^ | ^^^^
1087 | # __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics 1097 | # __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics
1088 | # Also multiprocessing.managers.SyncManager.dict() 1098 | # Also multiprocessing.managers.SyncManager.dict()
| |
info: Source info: Source
--> main.py:6:5 --> main.py:6:5
@ -620,7 +620,7 @@ f(**kwargs<CURSOR>)
6 | f(**kwargs) 6 | f(**kwargs)
| ^^^^^^ | ^^^^^^
| |
"#); "###);
} }
#[test] #[test]
@ -632,16 +632,16 @@ f(**kwargs<CURSOR>)
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r" assert_snapshot!(test.goto_type_definition(), @r###"
info[goto-type-definition]: Type definition info[goto-type-definition]: Type definition
--> stdlib/builtins.pyi:438:7 --> stdlib/builtins.pyi:445:7
| |
436 | def __getitem__(self, key: int, /) -> str | int | None: ... 443 | def __getitem__(self, key: int, /) -> str | int | None: ...
437 | 444 |
438 | class str(Sequence[str]): 445 | class str(Sequence[str]):
| ^^^ | ^^^
439 | @overload 446 | @overload
440 | def __new__(cls, object: object = ...) -> Self: ... 447 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> main.py:3:17 --> main.py:3:17
@ -650,7 +650,7 @@ f(**kwargs<CURSOR>)
3 | a 3 | a
| ^ | ^
| |
"); "###);
} }
#[test] #[test]
@ -725,16 +725,16 @@ f(**kwargs<CURSOR>)
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r" assert_snapshot!(test.goto_type_definition(), @r###"
info[goto-type-definition]: Type definition info[goto-type-definition]: Type definition
--> stdlib/builtins.pyi:438:7 --> stdlib/builtins.pyi:445:7
| |
436 | def __getitem__(self, key: int, /) -> str | int | None: ... 443 | def __getitem__(self, key: int, /) -> str | int | None: ...
437 | 444 |
438 | class str(Sequence[str]): 445 | class str(Sequence[str]):
| ^^^ | ^^^
439 | @overload 446 | @overload
440 | def __new__(cls, object: object = ...) -> Self: ... 447 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> main.py:4:27 --> main.py:4:27
@ -744,7 +744,7 @@ f(**kwargs<CURSOR>)
4 | print(a) 4 | print(a)
| ^ | ^
| |
"); "###);
} }
#[test] #[test]
@ -756,15 +756,15 @@ f(**kwargs<CURSOR>)
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r" assert_snapshot!(test.goto_type_definition(), @r###"
info[goto-type-definition]: Type definition info[goto-type-definition]: Type definition
--> stdlib/types.pyi:671:11 --> stdlib/types.pyi:680:11
| |
669 | if sys.version_info >= (3, 10): 678 | if sys.version_info >= (3, 10):
670 | @final 679 | @final
671 | class NoneType: 680 | class NoneType:
| ^^^^^^^^ | ^^^^^^^^
672 | def __bool__(self) -> Literal[False]: ... 681 | def __bool__(self) -> Literal[False]: ...
| |
info: Source info: Source
--> main.py:3:17 --> main.py:3:17
@ -775,14 +775,14 @@ f(**kwargs<CURSOR>)
| |
info[goto-type-definition]: Type definition info[goto-type-definition]: Type definition
--> stdlib/builtins.pyi:438:7 --> stdlib/builtins.pyi:445:7
| |
436 | def __getitem__(self, key: int, /) -> str | int | None: ... 443 | def __getitem__(self, key: int, /) -> str | int | None: ...
437 | 444 |
438 | class str(Sequence[str]): 445 | class str(Sequence[str]):
| ^^^ | ^^^
439 | @overload 446 | @overload
440 | def __new__(cls, object: object = ...) -> Self: ... 447 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> main.py:3:17 --> main.py:3:17
@ -791,7 +791,7 @@ f(**kwargs<CURSOR>)
3 | a 3 | a
| ^ | ^
| |
"); "###);
} }
impl CursorTest { impl CursorTest {

View file

@ -28,7 +28,7 @@ def f() -> None:
```py ```py
type IntOrStr = int | str type IntOrStr = int | str
reveal_type(IntOrStr.__value__) # revealed: Any reveal_type(IntOrStr.__value__) # revealed: @Todo(Support for `typing.TypeAlias`)
``` ```
## Invalid assignment ## Invalid assignment

View file

@ -21,7 +21,7 @@ the project the stubs are for, but instead report them here to typeshed.**
Further documentation on stub files, typeshed, and Python's typing system in Further documentation on stub files, typeshed, and Python's typing system in
general, can also be found at https://typing.readthedocs.io/en/latest/. general, can also be found at https://typing.readthedocs.io/en/latest/.
Typeshed supports Python versions 3.9 to 3.13. Typeshed supports Python versions 3.9 to 3.14.
## Using ## Using

View file

@ -1 +1 @@
eec809d049d10a5ae9b88780eab15fe36a9768d7 1063db7c15135c172f1f6a81d3aff6d1cb00a980

View file

@ -28,7 +28,7 @@ _bz2: 3.3-
_codecs: 3.0- _codecs: 3.0-
_collections_abc: 3.3- _collections_abc: 3.3-
_compat_pickle: 3.1- _compat_pickle: 3.1-
_compression: 3.5- _compression: 3.5-3.13
_contextvars: 3.7- _contextvars: 3.7-
_csv: 3.0- _csv: 3.0-
_ctypes: 3.0- _ctypes: 3.0-
@ -78,6 +78,7 @@ _weakrefset: 3.0-
_winapi: 3.3- _winapi: 3.3-
abc: 3.0- abc: 3.0-
aifc: 3.0-3.12 aifc: 3.0-3.12
annotationlib: 3.14-
antigravity: 3.0- antigravity: 3.0-
argparse: 3.0- argparse: 3.0-
array: 3.0- array: 3.0-
@ -86,6 +87,7 @@ asynchat: 3.0-3.11
asyncio: 3.4- asyncio: 3.4-
asyncio.exceptions: 3.8- asyncio.exceptions: 3.8-
asyncio.format_helpers: 3.7- asyncio.format_helpers: 3.7-
asyncio.graph: 3.14-
asyncio.mixins: 3.10- asyncio.mixins: 3.10-
asyncio.runners: 3.7- asyncio.runners: 3.7-
asyncio.staggered: 3.8- asyncio.staggered: 3.8-
@ -117,7 +119,9 @@ collections: 3.0-
collections.abc: 3.3- collections.abc: 3.3-
colorsys: 3.0- colorsys: 3.0-
compileall: 3.0- compileall: 3.0-
compression: 3.14-
concurrent: 3.2- concurrent: 3.2-
concurrent.futures.interpreter: 3.14-
configparser: 3.0- configparser: 3.0-
contextlib: 3.0- contextlib: 3.0-
contextvars: 3.7- contextvars: 3.7-
@ -226,6 +230,7 @@ os: 3.0-
ossaudiodev: 3.0-3.12 ossaudiodev: 3.0-3.12
parser: 3.0-3.9 parser: 3.0-3.9
pathlib: 3.4- pathlib: 3.4-
pathlib.types: 3.14-
pdb: 3.0- pdb: 3.0-
pickle: 3.0- pickle: 3.0-
pickletools: 3.0- pickletools: 3.0-
@ -278,6 +283,7 @@ ssl: 3.0-
stat: 3.0- stat: 3.0-
statistics: 3.4- statistics: 3.4-
string: 3.0- string: 3.0-
string.templatelib: 3.14-
stringprep: 3.0- stringprep: 3.0-
struct: 3.0- struct: 3.0-
subprocess: 3.0- subprocess: 3.0-

View file

@ -1,3 +1 @@
from typing import Any def __getattr__(name: str): ... # incomplete module
def __getattr__(name: str) -> Any: ...

View file

@ -111,13 +111,20 @@ from ast import (
from typing import Literal from typing import Literal
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
from ast import ParamSpec as ParamSpec, TypeVar as TypeVar, TypeVarTuple as TypeVarTuple, type_param as type_param from ast import (
ParamSpec as ParamSpec,
TypeAlias as TypeAlias,
TypeVar as TypeVar,
TypeVarTuple as TypeVarTuple,
type_param as type_param,
)
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
from ast import TryStar as TryStar from ast import TryStar as TryStar
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
from ast import ( from ast import (
Match as Match,
MatchAs as MatchAs, MatchAs as MatchAs,
MatchClass as MatchClass, MatchClass as MatchClass,
MatchMapping as MatchMapping, MatchMapping as MatchMapping,

View file

@ -1,4 +1,6 @@
from _typeshed import WriteableBuffer # _compression is replaced by compression._common._streams on Python 3.14+ (PEP-784)
from _typeshed import Incomplete, WriteableBuffer
from collections.abc import Callable from collections.abc import Callable
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
from typing import Any, Protocol from typing import Any, Protocol
@ -16,9 +18,9 @@ class DecompressReader(RawIOBase):
def __init__( def __init__(
self, self,
fp: _Reader, fp: _Reader,
decomp_factory: Callable[..., object], decomp_factory: Callable[..., Incomplete],
trailing_error: type[Exception] | tuple[type[Exception], ...] = (), trailing_error: type[Exception] | tuple[type[Exception], ...] = (),
**decomp_args: Any, **decomp_args: Any, # These are passed to decomp_factory.
) -> None: ... ) -> None: ...
def readinto(self, b: WriteableBuffer) -> int: ... def readinto(self, b: WriteableBuffer) -> int: ...
def read(self, size: int = -1) -> bytes: ... def read(self, size: int = -1) -> bytes: ...

View file

@ -1,5 +1,6 @@
import sys
from collections.abc import Callable, Iterator, Mapping from collections.abc import Callable, Iterator, Mapping
from types import GenericAlias from types import GenericAlias, TracebackType
from typing import Any, ClassVar, Generic, TypeVar, final, overload from typing import Any, ClassVar, Generic, TypeVar, final, overload
from typing_extensions import ParamSpec, Self from typing_extensions import ParamSpec, Self
@ -35,6 +36,11 @@ class Token(Generic[_T]):
MISSING: ClassVar[object] MISSING: ClassVar[object]
__hash__: ClassVar[None] # type: ignore[assignment] __hash__: ClassVar[None] # type: ignore[assignment]
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 14):
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> None: ...
def copy_context() -> Context: ... def copy_context() -> Context: ...

View file

@ -2,7 +2,7 @@ import csv
import sys import sys
from _typeshed import SupportsWrite from _typeshed import SupportsWrite
from collections.abc import Iterable from collections.abc import Iterable
from typing import Any, Final, type_check_only from typing import Any, Final, Literal, type_check_only
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
__version__: Final[str] __version__: Final[str]
@ -15,9 +15,10 @@ if sys.version_info >= (3, 12):
QUOTE_STRINGS: Final = 4 QUOTE_STRINGS: Final = 4
QUOTE_NOTNULL: Final = 5 QUOTE_NOTNULL: Final = 5
# Ideally this would be `QUOTE_ALL | QUOTE_MINIMAL | QUOTE_NONE | QUOTE_NONNUMERIC` if sys.version_info >= (3, 12):
# However, using literals in situations like these can cause false-positives (see #7258) _QuotingType: TypeAlias = Literal[0, 1, 2, 3, 4, 5]
_QuotingType: TypeAlias = int else:
_QuotingType: TypeAlias = Literal[0, 1, 2, 3]
class Error(Exception): ... class Error(Exception): ...

View file

@ -131,18 +131,23 @@ class _Pointer(_PointerLike, _CData, Generic[_CT], metaclass=_PyCPointerType):
def __getitem__(self, key: slice, /) -> list[Any]: ... def __getitem__(self, key: slice, /) -> list[Any]: ...
def __setitem__(self, key: int, value: Any, /) -> None: ... def __setitem__(self, key: int, value: Any, /) -> None: ...
@overload if sys.version_info < (3, 14):
def POINTER(type: None, /) -> type[c_void_p]: ... @overload
@overload def POINTER(type: None, /) -> type[c_void_p]: ...
def POINTER(type: type[_CT], /) -> type[_Pointer[_CT]]: ... @overload
def pointer(obj: _CT, /) -> _Pointer[_CT]: ... def POINTER(type: type[_CT], /) -> type[_Pointer[_CT]]: ...
def pointer(obj: _CT, /) -> _Pointer[_CT]: ...
# This class is not exposed. It calls itself _ctypes.CArgObject. # This class is not exposed. It calls itself _ctypes.CArgObject.
@final @final
@type_check_only @type_check_only
class _CArgObject: ... class _CArgObject: ...
def byref(obj: _CData | _CDataType, offset: int = ...) -> _CArgObject: ... if sys.version_info >= (3, 14):
def byref(obj: _CData | _CDataType, offset: int = 0, /) -> _CArgObject: ...
else:
def byref(obj: _CData | _CDataType, offset: int = 0) -> _CArgObject: ...
_ECT: TypeAlias = Callable[[_CData | _CDataType | None, CFuncPtr, tuple[_CData | _CDataType, ...]], _CDataType] _ECT: TypeAlias = Callable[[_CData | _CDataType | None, CFuncPtr, tuple[_CData | _CDataType, ...]], _CDataType]
_PF: TypeAlias = tuple[int] | tuple[int, str | None] | tuple[int, str | None, Any] _PF: TypeAlias = tuple[int] | tuple[int, str | None] | tuple[int, str | None, Any]

View file

@ -41,6 +41,8 @@ MAX_EMAX: Final[int]
MAX_PREC: Final[int] MAX_PREC: Final[int]
MIN_EMIN: Final[int] MIN_EMIN: Final[int]
MIN_ETINY: Final[int] MIN_ETINY: Final[int]
if sys.version_info >= (3, 14):
IEEE_CONTEXT_MAX_BITS: Final[int]
def setcontext(context: Context, /) -> None: ... def setcontext(context: Context, /) -> None: ...
def getcontext() -> Context: ... def getcontext() -> Context: ...
@ -62,6 +64,9 @@ if sys.version_info >= (3, 11):
else: else:
def localcontext(ctx: Context | None = None) -> _ContextManager: ... def localcontext(ctx: Context | None = None) -> _ContextManager: ...
if sys.version_info >= (3, 14):
def IEEEContext(bits: int, /) -> Context: ...
DefaultContext: Context DefaultContext: Context
BasicContext: Context BasicContext: Context
ExtendedContext: Context ExtendedContext: Context

View file

@ -88,9 +88,36 @@ class BytesIO(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore[misc]
def readlines(self, size: int | None = None, /) -> list[bytes]: ... def readlines(self, size: int | None = None, /) -> list[bytes]: ...
def seek(self, pos: int, whence: int = 0, /) -> int: ... def seek(self, pos: int, whence: int = 0, /) -> int: ...
class BufferedReader(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of methods in the base classes class _BufferedReaderStream(Protocol):
raw: RawIOBase def read(self, n: int = ..., /) -> bytes: ...
def __init__(self, raw: RawIOBase, buffer_size: int = 8192) -> None: ... # Optional: def readall(self) -> bytes: ...
def readinto(self, b: memoryview, /) -> int | None: ...
def seek(self, pos: int, whence: int, /) -> int: ...
def tell(self) -> int: ...
def truncate(self, size: int, /) -> int: ...
def flush(self) -> object: ...
def close(self) -> object: ...
@property
def closed(self) -> bool: ...
def readable(self) -> bool: ...
def seekable(self) -> bool: ...
# The following methods just pass through to the underlying stream. Since
# not all streams support them, they are marked as optional here, and will
# raise an AttributeError if called on a stream that does not support them.
# @property
# def name(self) -> Any: ... # Type is inconsistent between the various I/O types.
# @property
# def mode(self) -> str: ...
# def fileno(self) -> int: ...
# def isatty(self) -> bool: ...
_BufferedReaderStreamT = TypeVar("_BufferedReaderStreamT", bound=_BufferedReaderStream, default=_BufferedReaderStream)
class BufferedReader(BufferedIOBase, _BufferedIOBase, BinaryIO, Generic[_BufferedReaderStreamT]): # type: ignore[misc] # incompatible definitions of methods in the base classes
raw: _BufferedReaderStreamT
def __init__(self, raw: _BufferedReaderStreamT, buffer_size: int = 8192) -> None: ...
def peek(self, size: int = 0, /) -> bytes: ... def peek(self, size: int = 0, /) -> bytes: ...
def seek(self, target: int, whence: int = 0, /) -> int: ... def seek(self, target: int, whence: int = 0, /) -> int: ...
def truncate(self, pos: int | None = None, /) -> int: ... def truncate(self, pos: int | None = None, /) -> int: ...
@ -111,8 +138,8 @@ class BufferedRandom(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore
def peek(self, size: int = 0, /) -> bytes: ... def peek(self, size: int = 0, /) -> bytes: ...
def truncate(self, pos: int | None = None, /) -> int: ... def truncate(self, pos: int | None = None, /) -> int: ...
class BufferedRWPair(BufferedIOBase, _BufferedIOBase): class BufferedRWPair(BufferedIOBase, _BufferedIOBase, Generic[_BufferedReaderStreamT]):
def __init__(self, reader: RawIOBase, writer: RawIOBase, buffer_size: int = 8192, /) -> None: ... def __init__(self, reader: _BufferedReaderStreamT, writer: RawIOBase, buffer_size: int = 8192, /) -> None: ...
def peek(self, size: int = 0, /) -> bytes: ... def peek(self, size: int = 0, /) -> bytes: ...
class _TextIOBase(_IOBase): class _TextIOBase(_IOBase):
@ -131,8 +158,7 @@ class _TextIOBase(_IOBase):
@type_check_only @type_check_only
class _WrappedBuffer(Protocol): class _WrappedBuffer(Protocol):
# "name" is wrapped by TextIOWrapper. Its type is inconsistent between # "name" is wrapped by TextIOWrapper. Its type is inconsistent between
# the various I/O types, see the comments on TextIOWrapper.name and # the various I/O types.
# TextIO.name.
@property @property
def name(self) -> Any: ... def name(self) -> Any: ...
@property @property

View file

@ -1,5 +1,6 @@
# This is a slight lie, the implementations aren't exactly identical # This is a slight lie, the implementations aren't exactly identical
# However, in all likelihood, the differences are inconsequential # However, in all likelihood, the differences are inconsequential
import sys
from _decimal import * from _decimal import *
__all__ = [ __all__ = [
@ -41,3 +42,6 @@ __all__ = [
"HAVE_THREADS", "HAVE_THREADS",
"HAVE_CONTEXTVAR", "HAVE_CONTEXTVAR",
] ]
if sys.version_info >= (3, 14):
__all__ += ["IEEEContext", "IEEE_CONTEXT_MAX_BITS"]

View file

@ -229,6 +229,28 @@ if sys.platform != "win32":
IP_RECVOPTS: int IP_RECVOPTS: int
IP_RECVRETOPTS: int IP_RECVRETOPTS: int
IP_RETOPTS: int IP_RETOPTS: int
if sys.version_info >= (3, 14):
IP_RECVTTL: int
if sys.platform == "win32" or sys.platform == "linux":
IPV6_RECVERR: int
IP_RECVERR: int
SO_ORIGINAL_DST: int
if sys.platform == "win32":
SOL_RFCOMM: int
SO_BTH_ENCRYPT: int
SO_BTH_MTU: int
SO_BTH_MTU_MAX: int
SO_BTH_MTU_MIN: int
TCP_QUICKACK: int
if sys.platform == "linux":
CAN_RAW_ERR_FILTER: int
IP_FREEBIND: int
IP_RECVORIGDSTADDR: int
VMADDR_CID_LOCAL: int
if sys.platform != "win32" and sys.platform != "darwin": if sys.platform != "win32" and sys.platform != "darwin":
IP_TRANSPARENT: int IP_TRANSPARENT: int
if sys.platform != "win32" and sys.platform != "darwin" and sys.version_info >= (3, 11): if sys.platform != "win32" and sys.platform != "darwin" and sys.version_info >= (3, 11):
@ -829,6 +851,11 @@ if sys.platform != "win32":
def if_nameindex() -> list[tuple[int, str]]: ... def if_nameindex() -> list[tuple[int, str]]: ...
def if_nametoindex(oname: str, /) -> int: ... def if_nametoindex(oname: str, /) -> int: ...
def if_indextoname(index: int, /) -> str: ...
if sys.version_info >= (3, 14):
def if_indextoname(if_index: int, /) -> str: ...
else:
def if_indextoname(index: int, /) -> str: ...
CAPI: CapsuleType CAPI: CapsuleType

View file

@ -283,6 +283,8 @@ HAS_TLSv1: bool
HAS_TLSv1_1: bool HAS_TLSv1_1: bool
HAS_TLSv1_2: bool HAS_TLSv1_2: bool
HAS_TLSv1_3: bool HAS_TLSv1_3: bool
if sys.version_info >= (3, 14):
HAS_PHA: bool
# version info # version info
OPENSSL_VERSION_NUMBER: int OPENSSL_VERSION_NUMBER: int

View file

@ -353,7 +353,10 @@ class DataclassInstance(Protocol):
__dataclass_fields__: ClassVar[dict[str, Field[Any]]] __dataclass_fields__: ClassVar[dict[str, Field[Any]]]
# Anything that can be passed to the int/float constructors # Anything that can be passed to the int/float constructors
ConvertibleToInt: TypeAlias = str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc if sys.version_info >= (3, 14):
ConvertibleToInt: TypeAlias = str | ReadableBuffer | SupportsInt | SupportsIndex
else:
ConvertibleToInt: TypeAlias = str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc
ConvertibleToFloat: TypeAlias = str | ReadableBuffer | SupportsFloat | SupportsIndex ConvertibleToFloat: TypeAlias = str | ReadableBuffer | SupportsFloat | SupportsIndex
# A few classes updated from Foo(str, Enum) to Foo(StrEnum). This is a convenience so these # A few classes updated from Foo(str, Enum) to Foo(StrEnum). This is a convenience so these
@ -364,3 +367,14 @@ else:
from enum import Enum from enum import Enum
class StrEnum(str, Enum): ... class StrEnum(str, Enum): ...
# Objects that appear in annotations or in type expressions.
# Similar to PEP 747's TypeForm but a little broader.
AnnotationForm: TypeAlias = Any
if sys.version_info >= (3, 14):
from annotationlib import Format
# These return annotations, which can be arbitrary objects
AnnotateFunc: TypeAlias = Callable[[Format], dict[str, AnnotationForm]]
EvaluateFunc: TypeAlias = Callable[[Format], AnnotationForm]

View file

@ -0,0 +1,89 @@
# Internals used by some type checkers.
#
# Don't use this module directly. It is only for type checkers to use.
import sys
import typing_extensions
from _collections_abc import dict_items, dict_keys, dict_values
from abc import ABCMeta
from collections.abc import Awaitable, Generator, Iterable, Mapping
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing_extensions import Never
_T = TypeVar("_T")
# Used for an undocumented mypy feature. Does not exist at runtime.
promote = object()
# Fallback type providing methods and attributes that appear on all `TypedDict` types.
# N.B. Keep this mostly in sync with typing_extensions._TypedDict/mypy_extensions._TypedDict
class TypedDictFallback(Mapping[str, object], metaclass=ABCMeta):
__total__: ClassVar[bool]
__required_keys__: ClassVar[frozenset[str]]
__optional_keys__: ClassVar[frozenset[str]]
# __orig_bases__ sometimes exists on <3.12, but not consistently,
# so we only add it to the stub on 3.12+
if sys.version_info >= (3, 12):
__orig_bases__: ClassVar[tuple[Any, ...]]
if sys.version_info >= (3, 13):
__readonly_keys__: ClassVar[frozenset[str]]
__mutable_keys__: ClassVar[frozenset[str]]
def copy(self) -> typing_extensions.Self: ...
# Using Never so that only calls using mypy plugin hook that specialize the signature
# can go through.
def setdefault(self, k: Never, default: object) -> object: ...
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
def pop(self, k: Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
def update(self, m: typing_extensions.Self, /) -> None: ...
def __delitem__(self, k: Never) -> None: ...
def items(self) -> dict_items[str, object]: ...
def keys(self) -> dict_keys[str, object]: ...
def values(self) -> dict_values[str, object]: ...
@overload
def __or__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ...
@overload
def __or__(self, value: dict[str, Any], /) -> dict[str, object]: ...
@overload
def __ror__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ...
@overload
def __ror__(self, value: dict[str, Any], /) -> dict[str, object]: ...
# supposedly incompatible definitions of __or__ and __ior__
def __ior__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ... # type: ignore[misc]
# Fallback type providing methods and attributes that appear on all `NamedTuple` types.
class NamedTupleFallback(tuple[Any, ...]):
_field_defaults: ClassVar[dict[str, Any]]
_fields: ClassVar[tuple[str, ...]]
# __orig_bases__ sometimes exists on <3.12, but not consistently
# So we only add it to the stub on 3.12+.
if sys.version_info >= (3, 12):
__orig_bases__: ClassVar[tuple[Any, ...]]
@overload
def __init__(self, typename: str, fields: Iterable[tuple[str, Any]], /) -> None: ...
@overload
@typing_extensions.deprecated(
"Creating a typing.NamedTuple using keyword arguments is deprecated and support will be removed in Python 3.15"
)
def __init__(self, typename: str, fields: None = None, /, **kwargs: Any) -> None: ...
@classmethod
def _make(cls, iterable: Iterable[Any]) -> typing_extensions.Self: ...
def _asdict(self) -> dict[str, Any]: ...
def _replace(self, **kwargs: Any) -> typing_extensions.Self: ...
if sys.version_info >= (3, 13):
def __replace__(self, **kwargs: Any) -> typing_extensions.Self: ...
# Non-default variations to accommodate couroutines, and `AwaitableGenerator` having a 4th type parameter.
_S = TypeVar("_S")
_YieldT_co = TypeVar("_YieldT_co", covariant=True)
_SendT_nd_contra = TypeVar("_SendT_nd_contra", contravariant=True)
_ReturnT_nd_co = TypeVar("_ReturnT_nd_co", covariant=True)
# The parameters correspond to Generator, but the 4th is the original type.
class AwaitableGenerator(
Awaitable[_ReturnT_nd_co],
Generator[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co],
Generic[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co, _S],
metaclass=ABCMeta,
): ...

View file

@ -0,0 +1,132 @@
import sys
from typing import Literal
if sys.version_info >= (3, 14):
import enum
import types
from _typeshed import AnnotateFunc, AnnotationForm, EvaluateFunc, SupportsItems
from collections.abc import Mapping
from typing import Any, ParamSpec, TypeVar, TypeVarTuple, final, overload
from warnings import deprecated
__all__ = [
"Format",
"ForwardRef",
"call_annotate_function",
"call_evaluate_function",
"get_annotate_from_class_namespace",
"get_annotations",
"annotations_to_string",
"type_repr",
]
class Format(enum.IntEnum):
VALUE = 1
VALUE_WITH_FAKE_GLOBALS = 2
FORWARDREF = 3
STRING = 4
@final
class ForwardRef:
__forward_is_argument__: bool
__forward_is_class__: bool
__forward_module__: str | None
def __init__(
self, arg: str, *, module: str | None = None, owner: object = None, is_argument: bool = True, is_class: bool = False
) -> None: ...
@overload
def evaluate(
self,
*,
globals: dict[str, Any] | None = None,
locals: Mapping[str, Any] | None = None,
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] | None = None,
owner: object = None,
format: Literal[Format.STRING],
) -> str: ...
@overload
def evaluate(
self,
*,
globals: dict[str, Any] | None = None,
locals: Mapping[str, Any] | None = None,
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] | None = None,
owner: object = None,
format: Literal[Format.FORWARDREF],
) -> AnnotationForm | ForwardRef: ...
@overload
def evaluate(
self,
*,
globals: dict[str, Any] | None = None,
locals: Mapping[str, Any] | None = None,
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] | None = None,
owner: object = None,
format: Format = Format.VALUE, # noqa: Y011
) -> AnnotationForm: ...
@deprecated("Use ForwardRef.evaluate() or typing.evaluate_forward_ref() instead.")
def _evaluate(
self,
globalns: dict[str, Any] | None,
localns: Mapping[str, Any] | None,
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = ...,
*,
recursive_guard: frozenset[str],
) -> AnnotationForm: ...
@property
def __forward_arg__(self) -> str: ...
@property
def __forward_code__(self) -> types.CodeType: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def __or__(self, other: Any) -> types.UnionType: ...
def __ror__(self, other: Any) -> types.UnionType: ...
@overload
def call_evaluate_function(evaluate: EvaluateFunc, format: Literal[Format.STRING], *, owner: object = None) -> str: ...
@overload
def call_evaluate_function(
evaluate: EvaluateFunc, format: Literal[Format.FORWARDREF], *, owner: object = None
) -> AnnotationForm | ForwardRef: ...
@overload
def call_evaluate_function(evaluate: EvaluateFunc, format: Format, *, owner: object = None) -> AnnotationForm: ...
@overload
def call_annotate_function(
annotate: AnnotateFunc, format: Literal[Format.STRING], *, owner: object = None
) -> dict[str, str]: ...
@overload
def call_annotate_function(
annotate: AnnotateFunc, format: Literal[Format.FORWARDREF], *, owner: object = None
) -> dict[str, AnnotationForm | ForwardRef]: ...
@overload
def call_annotate_function(annotate: AnnotateFunc, format: Format, *, owner: object = None) -> dict[str, AnnotationForm]: ...
def get_annotate_from_class_namespace(obj: Mapping[str, object]) -> AnnotateFunc | None: ...
@overload
def get_annotations(
obj: Any, # any object with __annotations__ or __annotate__
*,
globals: dict[str, object] | None = None,
locals: Mapping[str, object] | None = None,
eval_str: bool = False,
format: Literal[Format.STRING],
) -> dict[str, str]: ...
@overload
def get_annotations(
obj: Any,
*,
globals: dict[str, object] | None = None,
locals: Mapping[str, object] | None = None,
eval_str: bool = False,
format: Literal[Format.FORWARDREF],
) -> dict[str, AnnotationForm | ForwardRef]: ...
@overload
def get_annotations(
obj: Any,
*,
globals: dict[str, object] | None = None,
locals: Mapping[str, object] | None = None,
eval_str: bool = False,
format: Format = Format.VALUE, # noqa: Y011
) -> dict[str, AnnotationForm]: ...
def type_repr(value: object) -> str: ...
def annotations_to_string(annotations: SupportsItems[str, object]) -> dict[str, str]: ...

View file

@ -123,6 +123,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
fromfile_prefix_chars: str | None fromfile_prefix_chars: str | None
add_help: bool add_help: bool
allow_abbrev: bool allow_abbrev: bool
exit_on_error: bool
if sys.version_info >= (3, 14):
suggest_on_error: bool
color: bool
# undocumented # undocumented
_positionals: _ArgumentGroup _positionals: _ArgumentGroup
@ -130,6 +135,27 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
_subparsers: _ArgumentGroup | None _subparsers: _ArgumentGroup | None
# Note: the constructor arguments are also used in _SubParsersAction.add_parser. # Note: the constructor arguments are also used in _SubParsersAction.add_parser.
if sys.version_info >= (3, 14):
def __init__(
self,
prog: str | None = None,
usage: str | None = None,
description: str | None = None,
epilog: str | None = None,
parents: Sequence[ArgumentParser] = [],
formatter_class: _FormatterClass = ...,
prefix_chars: str = "-",
fromfile_prefix_chars: str | None = None,
argument_default: Any = None,
conflict_handler: str = "error",
add_help: bool = True,
allow_abbrev: bool = True,
exit_on_error: bool = True,
*,
suggest_on_error: bool = False,
color: bool = False,
) -> None: ...
else:
def __init__( def __init__(
self, self,
prog: str | None = None, prog: str | None = None,
@ -146,6 +172,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
allow_abbrev: bool = True, allow_abbrev: bool = True,
exit_on_error: bool = True, exit_on_error: bool = True,
) -> None: ... ) -> None: ...
@overload @overload
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
@overload @overload
@ -252,7 +279,21 @@ class HelpFormatter:
def __init__(self, formatter: HelpFormatter, parent: Self | None, heading: str | None = None) -> None: ... def __init__(self, formatter: HelpFormatter, parent: Self | None, heading: str | None = None) -> None: ...
def format_help(self) -> str: ... def format_help(self) -> str: ...
def __init__(self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None) -> None: ... if sys.version_info >= (3, 14):
def __init__(
self,
prog: str,
indent_increment: int = 2,
max_help_position: int = 24,
width: int | None = None,
prefix_chars: str = "-",
color: bool = False,
) -> None: ...
else:
def __init__(
self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None
) -> None: ...
def _indent(self) -> None: ... def _indent(self) -> None: ...
def _dedent(self) -> None: ... def _dedent(self) -> None: ...
def _add_item(self, func: Callable[..., str], args: Iterable[Any]) -> None: ... def _add_item(self, func: Callable[..., str], args: Iterable[Any]) -> None: ...
@ -431,13 +472,29 @@ class Namespace(_AttributeHolder):
def __eq__(self, other: object) -> bool: ... def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment] __hash__: ClassVar[None] # type: ignore[assignment]
class FileType: if sys.version_info >= (3, 14):
@deprecated("Deprecated in Python 3.14; Simply open files after parsing arguments")
class FileType:
# undocumented # undocumented
_mode: str _mode: str
_bufsize: int _bufsize: int
_encoding: str | None _encoding: str | None
_errors: str | None _errors: str | None
def __init__(self, mode: str = "r", bufsize: int = -1, encoding: str | None = None, errors: str | None = None) -> None: ... def __init__(
self, mode: str = "r", bufsize: int = -1, encoding: str | None = None, errors: str | None = None
) -> None: ...
def __call__(self, string: str) -> IO[Any]: ...
else:
class FileType:
# undocumented
_mode: str
_bufsize: int
_encoding: str | None
_errors: str | None
def __init__(
self, mode: str = "r", bufsize: int = -1, encoding: str | None = None, errors: str | None = None
) -> None: ...
def __call__(self, string: str) -> IO[Any]: ... def __call__(self, string: str) -> IO[Any]: ...
# undocumented # undocumented
@ -668,7 +725,33 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
# Note: `add_parser` accepts all kwargs of `ArgumentParser.__init__`. It also # Note: `add_parser` accepts all kwargs of `ArgumentParser.__init__`. It also
# accepts its own `help` and `aliases` kwargs. # accepts its own `help` and `aliases` kwargs.
if sys.version_info >= (3, 13): if sys.version_info >= (3, 14):
def add_parser(
self,
name: str,
*,
deprecated: bool = False,
help: str | None = ...,
aliases: Sequence[str] = ...,
# Kwargs from ArgumentParser constructor
prog: str | None = ...,
usage: str | None = ...,
description: str | None = ...,
epilog: str | None = ...,
parents: Sequence[_ArgumentParserT] = ...,
formatter_class: _FormatterClass = ...,
prefix_chars: str = ...,
fromfile_prefix_chars: str | None = ...,
argument_default: Any = ...,
conflict_handler: str = ...,
add_help: bool = ...,
allow_abbrev: bool = ...,
exit_on_error: bool = ...,
suggest_on_error: bool = False,
color: bool = False,
**kwargs: Any, # Accepting any additional kwargs for custom parser classes
) -> _ArgumentParserT: ...
elif sys.version_info >= (3, 13):
def add_parser( def add_parser(
self, self,
name: str, name: str,

View file

@ -1,3 +1,4 @@
import builtins
import os import os
import sys import sys
import typing_extensions import typing_extensions
@ -7,19 +8,13 @@ from _ast import (
PyCF_TYPE_COMMENTS as PyCF_TYPE_COMMENTS, PyCF_TYPE_COMMENTS as PyCF_TYPE_COMMENTS,
) )
from _typeshed import ReadableBuffer, Unused from _typeshed import ReadableBuffer, Unused
from collections.abc import Iterable, Iterator from collections.abc import Iterable, Iterator, Sequence
from typing import Any, ClassVar, Generic, Literal, TypedDict, TypeVar as _TypeVar, overload from typing import Any, ClassVar, Generic, Literal, TypedDict, TypeVar as _TypeVar, overload
from typing_extensions import Self, Unpack, deprecated from typing_extensions import Self, Unpack, deprecated
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
from _ast import PyCF_OPTIMIZED_AST as PyCF_OPTIMIZED_AST from _ast import PyCF_OPTIMIZED_AST as PyCF_OPTIMIZED_AST
# Alias used for fields that must always be valid identifiers
# A string `x` counts as a valid identifier if both the following are True
# (1) `x.isidentifier()` evaluates to `True`
# (2) `keyword.iskeyword(x)` evaluates to `False`
_Identifier: typing_extensions.TypeAlias = str
# Used for node end positions in constructor keyword arguments # Used for node end positions in constructor keyword arguments
_EndPositionT = typing_extensions.TypeVar("_EndPositionT", int, int | None, default=int | None) _EndPositionT = typing_extensions.TypeVar("_EndPositionT", int, int | None, default=int | None)
@ -111,7 +106,7 @@ class FunctionDef(stmt):
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params") __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params")
elif sys.version_info >= (3, 10): elif sys.version_info >= (3, 10):
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")
name: _Identifier name: str
args: arguments args: arguments
body: list[stmt] body: list[stmt]
decorator_list: list[expr] decorator_list: list[expr]
@ -122,7 +117,7 @@ class FunctionDef(stmt):
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
args: arguments, args: arguments,
body: list[stmt] = ..., body: list[stmt] = ...,
decorator_list: list[expr] = ..., decorator_list: list[expr] = ...,
@ -135,7 +130,7 @@ class FunctionDef(stmt):
@overload @overload
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
args: arguments, args: arguments,
body: list[stmt], body: list[stmt],
decorator_list: list[expr], decorator_list: list[expr],
@ -147,7 +142,7 @@ class FunctionDef(stmt):
@overload @overload
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
args: arguments, args: arguments,
body: list[stmt], body: list[stmt],
decorator_list: list[expr], decorator_list: list[expr],
@ -160,7 +155,7 @@ class FunctionDef(stmt):
else: else:
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
args: arguments, args: arguments,
body: list[stmt], body: list[stmt],
decorator_list: list[expr], decorator_list: list[expr],
@ -173,13 +168,14 @@ class FunctionDef(stmt):
def __replace__( def __replace__(
self, self,
*, *,
name: _Identifier = ..., name: str = ...,
args: arguments = ..., args: arguments = ...,
body: list[stmt] = ..., body: list[stmt] = ...,
decorator_list: list[expr] = ..., decorator_list: list[expr] = ...,
returns: expr | None = ..., returns: expr | None = ...,
type_comment: str | None = ..., type_comment: str | None = ...,
type_params: list[type_param] = ..., type_params: list[type_param] = ...,
**kwargs: Unpack[_Attributes],
) -> Self: ... ) -> Self: ...
class AsyncFunctionDef(stmt): class AsyncFunctionDef(stmt):
@ -187,7 +183,7 @@ class AsyncFunctionDef(stmt):
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params") __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params")
elif sys.version_info >= (3, 10): elif sys.version_info >= (3, 10):
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")
name: _Identifier name: str
args: arguments args: arguments
body: list[stmt] body: list[stmt]
decorator_list: list[expr] decorator_list: list[expr]
@ -198,7 +194,7 @@ class AsyncFunctionDef(stmt):
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
args: arguments, args: arguments,
body: list[stmt] = ..., body: list[stmt] = ...,
decorator_list: list[expr] = ..., decorator_list: list[expr] = ...,
@ -211,7 +207,7 @@ class AsyncFunctionDef(stmt):
@overload @overload
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
args: arguments, args: arguments,
body: list[stmt], body: list[stmt],
decorator_list: list[expr], decorator_list: list[expr],
@ -223,7 +219,7 @@ class AsyncFunctionDef(stmt):
@overload @overload
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
args: arguments, args: arguments,
body: list[stmt], body: list[stmt],
decorator_list: list[expr], decorator_list: list[expr],
@ -236,7 +232,7 @@ class AsyncFunctionDef(stmt):
else: else:
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
args: arguments, args: arguments,
body: list[stmt], body: list[stmt],
decorator_list: list[expr], decorator_list: list[expr],
@ -249,13 +245,14 @@ class AsyncFunctionDef(stmt):
def __replace__( def __replace__(
self, self,
*, *,
name: _Identifier = ..., name: str = ...,
args: arguments = ..., args: arguments = ...,
body: list[stmt], body: list[stmt] = ...,
decorator_list: list[expr], decorator_list: list[expr] = ...,
returns: expr | None, returns: expr | None = ...,
type_comment: str | None, type_comment: str | None = ...,
type_params: list[type_param], type_params: list[type_param] = ...,
**kwargs: Unpack[_Attributes],
) -> Self: ... ) -> Self: ...
class ClassDef(stmt): class ClassDef(stmt):
@ -263,7 +260,7 @@ class ClassDef(stmt):
__match_args__ = ("name", "bases", "keywords", "body", "decorator_list", "type_params") __match_args__ = ("name", "bases", "keywords", "body", "decorator_list", "type_params")
elif sys.version_info >= (3, 10): elif sys.version_info >= (3, 10):
__match_args__ = ("name", "bases", "keywords", "body", "decorator_list") __match_args__ = ("name", "bases", "keywords", "body", "decorator_list")
name: _Identifier name: str
bases: list[expr] bases: list[expr]
keywords: list[keyword] keywords: list[keyword]
body: list[stmt] body: list[stmt]
@ -273,7 +270,7 @@ class ClassDef(stmt):
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
bases: list[expr] = ..., bases: list[expr] = ...,
keywords: list[keyword] = ..., keywords: list[keyword] = ...,
body: list[stmt] = ..., body: list[stmt] = ...,
@ -284,7 +281,7 @@ class ClassDef(stmt):
elif sys.version_info >= (3, 12): elif sys.version_info >= (3, 12):
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
bases: list[expr], bases: list[expr],
keywords: list[keyword], keywords: list[keyword],
body: list[stmt], body: list[stmt],
@ -295,7 +292,7 @@ class ClassDef(stmt):
else: else:
def __init__( def __init__(
self, self,
name: _Identifier, name: str,
bases: list[expr], bases: list[expr],
keywords: list[keyword], keywords: list[keyword],
body: list[stmt], body: list[stmt],
@ -307,12 +304,12 @@ class ClassDef(stmt):
def __replace__( def __replace__(
self, self,
*, *,
name: _Identifier, name: str = ...,
bases: list[expr], bases: list[expr] = ...,
keywords: list[keyword], keywords: list[keyword] = ...,
body: list[stmt], body: list[stmt] = ...,
decorator_list: list[expr], decorator_list: list[expr] = ...,
type_params: list[type_param], type_params: list[type_param] = ...,
**kwargs: Unpack[_Attributes], **kwargs: Unpack[_Attributes],
) -> Self: ... ) -> Self: ...
@ -383,7 +380,7 @@ if sys.version_info >= (3, 12):
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__( def __replace__( # type: ignore[override]
self, self,
*, *,
name: Name = ..., name: Name = ...,
@ -546,7 +543,9 @@ class While(stmt):
def __init__(self, test: expr, body: list[stmt], orelse: list[stmt], **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, test: expr, body: list[stmt], orelse: list[stmt], **kwargs: Unpack[_Attributes]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__(self, *, test: expr, body: list[stmt], orelse: list[stmt], **kwargs: Unpack[_Attributes]) -> Self: ... def __replace__(
self, *, test: expr = ..., body: list[stmt] = ..., orelse: list[stmt] = ..., **kwargs: Unpack[_Attributes]
) -> Self: ...
class If(stmt): class If(stmt):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@ -731,7 +730,7 @@ class Assert(stmt):
def __init__(self, test: expr, msg: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, test: expr, msg: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__(self, *, test: expr, msg: expr | None, **kwargs: Unpack[_Attributes]) -> Self: ... def __replace__(self, *, test: expr = ..., msg: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
class Import(stmt): class Import(stmt):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@ -774,26 +773,26 @@ class ImportFrom(stmt):
class Global(stmt): class Global(stmt):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__match_args__ = ("names",) __match_args__ = ("names",)
names: list[_Identifier] names: list[str]
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __init__(self, names: list[_Identifier] = ..., **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
else: else:
def __init__(self, names: list[_Identifier], **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, names: list[str], **kwargs: Unpack[_Attributes]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__(self, *, names: list[_Identifier], **kwargs: Unpack[_Attributes]) -> Self: ... def __replace__(self, *, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
class Nonlocal(stmt): class Nonlocal(stmt):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__match_args__ = ("names",) __match_args__ = ("names",)
names: list[_Identifier] names: list[str]
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __init__(self, names: list[_Identifier] = ..., **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
else: else:
def __init__(self, names: list[_Identifier], **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, names: list[str], **kwargs: Unpack[_Attributes]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__(self, *, names: list[_Identifier] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... def __replace__(self, *, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
class Expr(stmt): class Expr(stmt):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@ -1065,6 +1064,37 @@ class JoinedStr(expr):
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__(self, *, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... def __replace__(self, *, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
if sys.version_info >= (3, 14):
class TemplateStr(expr):
__match_args__ = ("values",)
values: list[expr]
def __init__(self, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
def __replace__(self, *, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
class Interpolation(expr):
__match_args__ = ("value", "str", "conversion", "format_spec")
value: expr
str: builtins.str
conversion: int
format_spec: builtins.str | None = None
def __init__(
self,
value: expr = ...,
str: builtins.str = ...,
conversion: int = ...,
format_spec: builtins.str | None = ...,
**kwargs: Unpack[_Attributes],
) -> None: ...
def __replace__(
self,
*,
value: expr = ...,
str: builtins.str = ...,
conversion: int = ...,
format_spec: builtins.str | None = ...,
**kwargs: Unpack[_Attributes],
) -> Self: ...
class Constant(expr): class Constant(expr):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__match_args__ = ("value", "kind") __match_args__ = ("value", "kind")
@ -1084,13 +1114,13 @@ class Attribute(expr):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__match_args__ = ("value", "attr", "ctx") __match_args__ = ("value", "attr", "ctx")
value: expr value: expr
attr: _Identifier attr: str
ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
def __init__(self, value: expr, attr: _Identifier, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, value: expr, attr: str, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__( def __replace__(
self, *, value: expr = ..., attr: _Identifier = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes] self, *, value: expr = ..., attr: str = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]
) -> Self: ... ) -> Self: ...
class Subscript(expr): class Subscript(expr):
@ -1119,12 +1149,12 @@ class Starred(expr):
class Name(expr): class Name(expr):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__match_args__ = ("id", "ctx") __match_args__ = ("id", "ctx")
id: _Identifier id: str
ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
def __init__(self, id: _Identifier, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, id: str, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__(self, *, id: _Identifier = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... def __replace__(self, *, id: str = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
class List(expr): class List(expr):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@ -1272,30 +1302,23 @@ class ExceptHandler(excepthandler):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__match_args__ = ("type", "name", "body") __match_args__ = ("type", "name", "body")
type: expr | None type: expr | None
name: _Identifier | None name: str | None
body: list[stmt] body: list[stmt]
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __init__( def __init__(
self, type: expr | None = None, name: _Identifier | None = None, body: list[stmt] = ..., **kwargs: Unpack[_Attributes] self, type: expr | None = None, name: str | None = None, body: list[stmt] = ..., **kwargs: Unpack[_Attributes]
) -> None: ... ) -> None: ...
else: else:
@overload @overload
def __init__( def __init__(self, type: expr | None, name: str | None, body: list[stmt], **kwargs: Unpack[_Attributes]) -> None: ...
self, type: expr | None, name: _Identifier | None, body: list[stmt], **kwargs: Unpack[_Attributes]
) -> None: ...
@overload @overload
def __init__( def __init__(
self, type: expr | None = None, name: _Identifier | None = None, *, body: list[stmt], **kwargs: Unpack[_Attributes] self, type: expr | None = None, name: str | None = None, *, body: list[stmt], **kwargs: Unpack[_Attributes]
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__( def __replace__(
self, self, *, type: expr | None = ..., name: str | None = ..., body: list[stmt] = ..., **kwargs: Unpack[_Attributes]
*,
type: expr | None = ...,
name: _Identifier | None = ...,
body: list[stmt] = ...,
**kwargs: Unpack[_Attributes],
) -> Self: ... ) -> Self: ...
class arguments(AST): class arguments(AST):
@ -1376,21 +1399,16 @@ class arg(AST):
end_col_offset: int | None end_col_offset: int | None
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__match_args__ = ("arg", "annotation", "type_comment") __match_args__ = ("arg", "annotation", "type_comment")
arg: _Identifier arg: str
annotation: expr | None annotation: expr | None
type_comment: str | None type_comment: str | None
def __init__( def __init__(
self, arg: _Identifier, annotation: expr | None = None, type_comment: str | None = None, **kwargs: Unpack[_Attributes] self, arg: str, annotation: expr | None = None, type_comment: str | None = None, **kwargs: Unpack[_Attributes]
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__( def __replace__(
self, self, *, arg: str = ..., annotation: expr | None = ..., type_comment: str | None = ..., **kwargs: Unpack[_Attributes]
*,
arg: _Identifier = ...,
annotation: expr | None = ...,
type_comment: str | None = ...,
**kwargs: Unpack[_Attributes],
) -> Self: ... ) -> Self: ...
class keyword(AST): class keyword(AST):
@ -1400,15 +1418,15 @@ class keyword(AST):
end_col_offset: int | None end_col_offset: int | None
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__match_args__ = ("arg", "value") __match_args__ = ("arg", "value")
arg: _Identifier | None arg: str | None
value: expr value: expr
@overload @overload
def __init__(self, arg: _Identifier | None, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, arg: str | None, value: expr, **kwargs: Unpack[_Attributes]) -> None: ...
@overload @overload
def __init__(self, arg: _Identifier | None = None, *, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, arg: str | None = None, *, value: expr, **kwargs: Unpack[_Attributes]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__(self, *, arg: _Identifier | None = ..., value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... def __replace__(self, *, arg: str | None = ..., value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
class alias(AST): class alias(AST):
lineno: int lineno: int
@ -1418,11 +1436,11 @@ class alias(AST):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__match_args__ = ("name", "asname") __match_args__ = ("name", "asname")
name: str name: str
asname: _Identifier | None asname: str | None
def __init__(self, name: str, asname: _Identifier | None = None, **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__(self, *, name: str = ..., asname: _Identifier | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... def __replace__(self, *, name: str = ..., asname: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
class withitem(AST): class withitem(AST):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@ -1497,22 +1515,18 @@ if sys.version_info >= (3, 10):
__match_args__ = ("keys", "patterns", "rest") __match_args__ = ("keys", "patterns", "rest")
keys: list[expr] keys: list[expr]
patterns: list[pattern] patterns: list[pattern]
rest: _Identifier | None rest: str | None
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __init__( def __init__(
self, self,
keys: list[expr] = ..., keys: list[expr] = ...,
patterns: list[pattern] = ..., patterns: list[pattern] = ...,
rest: _Identifier | None = None, rest: str | None = None,
**kwargs: Unpack[_Attributes[int]], **kwargs: Unpack[_Attributes[int]],
) -> None: ... ) -> None: ...
else: else:
def __init__( def __init__(
self, self, keys: list[expr], patterns: list[pattern], rest: str | None = None, **kwargs: Unpack[_Attributes[int]]
keys: list[expr],
patterns: list[pattern],
rest: _Identifier | None = None,
**kwargs: Unpack[_Attributes[int]],
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
@ -1521,7 +1535,7 @@ if sys.version_info >= (3, 10):
*, *,
keys: list[expr] = ..., keys: list[expr] = ...,
patterns: list[pattern] = ..., patterns: list[pattern] = ...,
rest: _Identifier | None = ..., rest: str | None = ...,
**kwargs: Unpack[_Attributes[int]], **kwargs: Unpack[_Attributes[int]],
) -> Self: ... ) -> Self: ...
@ -1529,14 +1543,14 @@ if sys.version_info >= (3, 10):
__match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns") __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns")
cls: expr cls: expr
patterns: list[pattern] patterns: list[pattern]
kwd_attrs: list[_Identifier] kwd_attrs: list[str]
kwd_patterns: list[pattern] kwd_patterns: list[pattern]
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __init__( def __init__(
self, self,
cls: expr, cls: expr,
patterns: list[pattern] = ..., patterns: list[pattern] = ...,
kwd_attrs: list[_Identifier] = ..., kwd_attrs: list[str] = ...,
kwd_patterns: list[pattern] = ..., kwd_patterns: list[pattern] = ...,
**kwargs: Unpack[_Attributes[int]], **kwargs: Unpack[_Attributes[int]],
) -> None: ... ) -> None: ...
@ -1545,7 +1559,7 @@ if sys.version_info >= (3, 10):
self, self,
cls: expr, cls: expr,
patterns: list[pattern], patterns: list[pattern],
kwd_attrs: list[_Identifier], kwd_attrs: list[str],
kwd_patterns: list[pattern], kwd_patterns: list[pattern],
**kwargs: Unpack[_Attributes[int]], **kwargs: Unpack[_Attributes[int]],
) -> None: ... ) -> None: ...
@ -1556,30 +1570,30 @@ if sys.version_info >= (3, 10):
*, *,
cls: expr = ..., cls: expr = ...,
patterns: list[pattern] = ..., patterns: list[pattern] = ...,
kwd_attrs: list[_Identifier] = ..., kwd_attrs: list[str] = ...,
kwd_patterns: list[pattern] = ..., kwd_patterns: list[pattern] = ...,
**kwargs: Unpack[_Attributes[int]], **kwargs: Unpack[_Attributes[int]],
) -> Self: ... ) -> Self: ...
class MatchStar(pattern): class MatchStar(pattern):
__match_args__ = ("name",) __match_args__ = ("name",)
name: _Identifier | None name: str | None
def __init__(self, name: _Identifier | None, **kwargs: Unpack[_Attributes[int]]) -> None: ... def __init__(self, name: str | None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__(self, *, name: _Identifier | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... def __replace__(self, *, name: str | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ...
class MatchAs(pattern): class MatchAs(pattern):
__match_args__ = ("pattern", "name") __match_args__ = ("pattern", "name")
pattern: _Pattern | None pattern: _Pattern | None
name: _Identifier | None name: str | None
def __init__( def __init__(
self, pattern: _Pattern | None = None, name: _Identifier | None = None, **kwargs: Unpack[_Attributes[int]] self, pattern: _Pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]]
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__( def __replace__(
self, *, pattern: _Pattern | None = ..., name: _Identifier | None = ..., **kwargs: Unpack[_Attributes[int]] self, *, pattern: _Pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]]
) -> Self: ... ) -> Self: ...
class MatchOr(pattern): class MatchOr(pattern):
@ -1621,25 +1635,21 @@ if sys.version_info >= (3, 12):
__match_args__ = ("name", "bound", "default_value") __match_args__ = ("name", "bound", "default_value")
else: else:
__match_args__ = ("name", "bound") __match_args__ = ("name", "bound")
name: _Identifier name: str
bound: expr | None bound: expr | None
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
default_value: expr | None default_value: expr | None
def __init__( def __init__(
self, self, name: str, bound: expr | None = None, default_value: expr | None = None, **kwargs: Unpack[_Attributes[int]]
name: _Identifier,
bound: expr | None = None,
default_value: expr | None = None,
**kwargs: Unpack[_Attributes[int]],
) -> None: ... ) -> None: ...
else: else:
def __init__(self, name: _Identifier, bound: expr | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ... def __init__(self, name: str, bound: expr | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__( def __replace__(
self, self,
*, *,
name: _Identifier = ..., name: str = ...,
bound: expr | None = ..., bound: expr | None = ...,
default_value: expr | None = ..., default_value: expr | None = ...,
**kwargs: Unpack[_Attributes[int]], **kwargs: Unpack[_Attributes[int]],
@ -1650,18 +1660,16 @@ if sys.version_info >= (3, 12):
__match_args__ = ("name", "default_value") __match_args__ = ("name", "default_value")
else: else:
__match_args__ = ("name",) __match_args__ = ("name",)
name: _Identifier name: str
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
default_value: expr | None default_value: expr | None
def __init__( def __init__(self, name: str, default_value: expr | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
self, name: _Identifier, default_value: expr | None = None, **kwargs: Unpack[_Attributes[int]]
) -> None: ...
else: else:
def __init__(self, name: _Identifier, **kwargs: Unpack[_Attributes[int]]) -> None: ... def __init__(self, name: str, **kwargs: Unpack[_Attributes[int]]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__( def __replace__(
self, *, name: _Identifier = ..., default_value: expr | None = ..., **kwargs: Unpack[_Attributes[int]] self, *, name: str = ..., default_value: expr | None = ..., **kwargs: Unpack[_Attributes[int]]
) -> Self: ... ) -> Self: ...
class TypeVarTuple(type_param): class TypeVarTuple(type_param):
@ -1669,18 +1677,16 @@ if sys.version_info >= (3, 12):
__match_args__ = ("name", "default_value") __match_args__ = ("name", "default_value")
else: else:
__match_args__ = ("name",) __match_args__ = ("name",)
name: _Identifier name: str
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
default_value: expr | None default_value: expr | None
def __init__( def __init__(self, name: str, default_value: expr | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
self, name: _Identifier, default_value: expr | None = None, **kwargs: Unpack[_Attributes[int]]
) -> None: ...
else: else:
def __init__(self, name: _Identifier, **kwargs: Unpack[_Attributes[int]]) -> None: ... def __init__(self, name: str, **kwargs: Unpack[_Attributes[int]]) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def __replace__( def __replace__(
self, *, name: _Identifier = ..., default_value: expr | None = ..., **kwargs: Unpack[_Attributes[int]] self, *, name: str = ..., default_value: expr | None = ..., **kwargs: Unpack[_Attributes[int]]
) -> Self: ... ) -> Self: ...
class _ABC(type): class _ABC(type):
@ -2042,4 +2048,9 @@ class NodeTransformer(NodeVisitor):
# is also allowed in some cases -- this needs to be mapped. # is also allowed in some cases -- this needs to be mapped.
def unparse(ast_obj: AST) -> str: ... def unparse(ast_obj: AST) -> str: ...
def main() -> None: ...
if sys.version_info >= (3, 14):
def main(args: Sequence[str] | None = None) -> None: ...
else:
def main() -> None: ...

View file

@ -21,6 +21,9 @@ from .tasks import *
from .threads import * from .threads import *
from .transports import * from .transports import *
if sys.version_info >= (3, 14):
from .graph import *
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
from .taskgroups import * from .taskgroups import *
from .timeouts import * from .timeouts import *
@ -32,6 +35,7 @@ else:
if sys.platform == "win32": if sys.platform == "win32":
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
__all__ = ( __all__ = (
"BaseEventLoop", # from base_events "BaseEventLoop", # from base_events
"Server", # from base_events "Server", # from base_events
@ -60,6 +64,13 @@ if sys.platform == "win32":
"Future", # from futures "Future", # from futures
"wrap_future", # from futures "wrap_future", # from futures
"isfuture", # from futures "isfuture", # from futures
"future_discard_from_awaited_by", # from futures
"future_add_to_awaited_by", # from futures
"capture_call_graph", # from graph
"format_call_graph", # from graph
"print_call_graph", # from graph
"FrameCallGraphEntry", # from graph
"FutureCallGraph", # from graph
"Lock", # from locks "Lock", # from locks
"Event", # from locks "Event", # from locks
"Condition", # from locks "Condition", # from locks
@ -527,6 +538,13 @@ else:
"Future", # from futures "Future", # from futures
"wrap_future", # from futures "wrap_future", # from futures
"isfuture", # from futures "isfuture", # from futures
"future_discard_from_awaited_by", # from futures
"future_add_to_awaited_by", # from futures
"capture_call_graph", # from graph
"format_call_graph", # from graph
"print_call_graph", # from graph
"FrameCallGraphEntry", # from graph
"FutureCallGraph", # from graph
"Lock", # from locks "Lock", # from locks
"Event", # from locks "Event", # from locks
"Condition", # from locks "Condition", # from locks

View file

@ -21,7 +21,9 @@ from .futures import Future
from .protocols import BaseProtocol from .protocols import BaseProtocol
from .tasks import Task from .tasks import Task
from .transports import BaseTransport, DatagramTransport, ReadTransport, SubprocessTransport, Transport, WriteTransport from .transports import BaseTransport, DatagramTransport, ReadTransport, SubprocessTransport, Transport, WriteTransport
from .unix_events import AbstractChildWatcher
if sys.version_info < (3, 14):
from .unix_events import AbstractChildWatcher
# Keep asyncio.__all__ updated with any changes to __all__ here # Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):

View file

@ -1,3 +1,4 @@
import sys
from _asyncio import Future as Future from _asyncio import Future as Future
from concurrent.futures._base import Future as _ConcurrentFuture from concurrent.futures._base import Future as _ConcurrentFuture
from typing import Any, TypeVar from typing import Any, TypeVar
@ -6,7 +7,10 @@ from typing_extensions import TypeIs
from .events import AbstractEventLoop from .events import AbstractEventLoop
# Keep asyncio.__all__ updated with any changes to __all__ here # Keep asyncio.__all__ updated with any changes to __all__ here
__all__ = ("Future", "wrap_future", "isfuture") if sys.version_info >= (3, 14):
__all__ = ("Future", "wrap_future", "isfuture", "future_discard_from_awaited_by", "future_add_to_awaited_by")
else:
__all__ = ("Future", "wrap_future", "isfuture")
_T = TypeVar("_T") _T = TypeVar("_T")
@ -15,3 +19,7 @@ _T = TypeVar("_T")
# That's why the import order is reversed. # That's why the import order is reversed.
def isfuture(obj: object) -> TypeIs[Future[Any]]: ... def isfuture(obj: object) -> TypeIs[Future[Any]]: ...
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ... def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...
if sys.version_info >= (3, 14):
def future_discard_from_awaited_by(future: Future[Any], waiter: Future[Any], /) -> None: ...
def future_add_to_awaited_by(future: Future[Any], waiter: Future[Any], /) -> None: ...

View file

@ -0,0 +1,26 @@
from _typeshed import SupportsWrite
from asyncio import Future
from dataclasses import dataclass
from types import FrameType
from typing import Any, overload
__all__ = ("capture_call_graph", "format_call_graph", "print_call_graph", "FrameCallGraphEntry", "FutureCallGraph")
@dataclass(frozen=True)
class FrameCallGraphEntry:
frame: FrameType
@dataclass(frozen=True)
class FutureCallGraph:
future: Future[Any]
call_stack: tuple[FrameCallGraphEntry, ...]
awaited_by: tuple[FutureCallGraph, ...]
@overload
def capture_call_graph(future: None = None, /, *, depth: int = 1, limit: int | None = None) -> FutureCallGraph | None: ...
@overload
def capture_call_graph(future: Future[Any], /, *, depth: int = 1, limit: int | None = None) -> FutureCallGraph | None: ...
def format_call_graph(future: Future[Any] | None = None, /, *, depth: int = 1, limit: int | None = None) -> str: ...
def print_call_graph(
future: Future[Any] | None = None, /, *, file: SupportsWrite[str] | None = None, depth: int = 1, limit: int | None = None
) -> None: ...

View file

@ -3,13 +3,14 @@ from _typeshed import ExcInfo, TraceFunction, Unused
from collections.abc import Callable, Iterable, Iterator, Mapping from collections.abc import Callable, Iterable, Iterator, Mapping
from contextlib import contextmanager from contextlib import contextmanager
from types import CodeType, FrameType, TracebackType from types import CodeType, FrameType, TracebackType
from typing import IO, Any, Final, SupportsInt, TypeVar from typing import IO, Any, Final, Literal, SupportsInt, TypeVar
from typing_extensions import ParamSpec from typing_extensions import ParamSpec, TypeAlias
__all__ = ["BdbQuit", "Bdb", "Breakpoint"] __all__ = ["BdbQuit", "Bdb", "Breakpoint"]
_T = TypeVar("_T") _T = TypeVar("_T")
_P = ParamSpec("_P") _P = ParamSpec("_P")
_Backend: TypeAlias = Literal["settrace", "monitoring"]
# A union of code-object flags at runtime. # A union of code-object flags at runtime.
# The exact values of code-object flags are implementation details, # The exact values of code-object flags are implementation details,
@ -28,7 +29,12 @@ class Bdb:
stopframe: FrameType | None stopframe: FrameType | None
returnframe: FrameType | None returnframe: FrameType | None
stoplineno: int stoplineno: int
if sys.version_info >= (3, 14):
backend: _Backend
def __init__(self, skip: Iterable[str] | None = None, backend: _Backend = "settrace") -> None: ...
else:
def __init__(self, skip: Iterable[str] | None = None) -> None: ... def __init__(self, skip: Iterable[str] | None = None) -> None: ...
def canonic(self, filename: str) -> str: ... def canonic(self, filename: str) -> str: ...
def reset(self) -> None: ... def reset(self) -> None: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
@ -85,6 +91,11 @@ class Bdb:
def runeval(self, expr: str, globals: dict[str, Any] | None = None, locals: Mapping[str, Any] | None = None) -> None: ... def runeval(self, expr: str, globals: dict[str, Any] | None = None, locals: Mapping[str, Any] | None = None) -> None: ...
def runctx(self, cmd: str | CodeType, globals: dict[str, Any] | None, locals: Mapping[str, Any] | None) -> None: ... def runctx(self, cmd: str | CodeType, globals: dict[str, Any] | None, locals: Mapping[str, Any] | None) -> None: ...
def runcall(self, func: Callable[_P, _T], /, *args: _P.args, **kwds: _P.kwargs) -> _T | None: ... def runcall(self, func: Callable[_P, _T], /, *args: _P.args, **kwds: _P.kwargs) -> _T | None: ...
if sys.version_info >= (3, 14):
def start_trace(self) -> None: ...
def stop_trace(self) -> None: ...
def disable_current_event(self) -> None: ...
def restart_events(self) -> None: ...
class Breakpoint: class Breakpoint:
next: int next: int

View file

@ -5,6 +5,7 @@ import sys
import types import types
from _collections_abc import dict_items, dict_keys, dict_values from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import ( from _typeshed import (
AnnotationForm,
AnyStr_co, AnyStr_co,
ConvertibleToFloat, ConvertibleToFloat,
ConvertibleToInt, ConvertibleToInt,
@ -72,6 +73,9 @@ from typing_extensions import ( # noqa: Y023
deprecated, deprecated,
) )
if sys.version_info >= (3, 14):
from _typeshed import AnnotateFunc
_T = TypeVar("_T") _T = TypeVar("_T")
_I = TypeVar("_I", default=int) _I = TypeVar("_I", default=int)
_T_co = TypeVar("_T_co", covariant=True) _T_co = TypeVar("_T_co", covariant=True)
@ -215,6 +219,9 @@ class type:
def __ror__(self, value: Any, /) -> types.UnionType: ... def __ror__(self, value: Any, /) -> types.UnionType: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
__type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...]
__annotations__: dict[str, AnnotationForm]
if sys.version_info >= (3, 14):
__annotate__: AnnotateFunc | None
class super: class super:
@overload @overload
@ -1004,6 +1011,7 @@ class tuple(Sequence[_T_co]):
# Doesn't exist at runtime, but deleting this breaks mypy and pyright. See: # Doesn't exist at runtime, but deleting this breaks mypy and pyright. See:
# https://github.com/python/typeshed/issues/7580 # https://github.com/python/typeshed/issues/7580
# https://github.com/python/mypy/issues/8240 # https://github.com/python/mypy/issues/8240
# Obsolete, use types.FunctionType instead.
@final @final
@type_check_only @type_check_only
class function: class function:
@ -1017,7 +1025,9 @@ class function:
def __globals__(self) -> dict[str, Any]: ... def __globals__(self) -> dict[str, Any]: ...
__name__: str __name__: str
__qualname__: str __qualname__: str
__annotations__: dict[str, Any] __annotations__: dict[str, AnnotationForm]
if sys.version_info >= (3, 14):
__annotate__: AnnotateFunc | None
__kwdefaults__: dict[str, Any] __kwdefaults__: dict[str, Any]
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@property @property
@ -1494,6 +1504,65 @@ license: _sitebuiltins._Printer
def locals() -> dict[str, Any]: ... def locals() -> dict[str, Any]: ...
class map(Generic[_S]): class map(Generic[_S]):
# 3.14 adds `strict` argument.
if sys.version_info >= (3, 14):
@overload
def __new__(cls, func: Callable[[_T1], _S], iterable: Iterable[_T1], /, *, strict: bool = False) -> Self: ...
@overload
def __new__(
cls, func: Callable[[_T1, _T2], _S], iterable: Iterable[_T1], iter2: Iterable[_T2], /, *, strict: bool = False
) -> Self: ...
@overload
def __new__(
cls,
func: Callable[[_T1, _T2, _T3], _S],
iterable: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3],
/,
*,
strict: bool = False,
) -> Self: ...
@overload
def __new__(
cls,
func: Callable[[_T1, _T2, _T3, _T4], _S],
iterable: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3],
iter4: Iterable[_T4],
/,
*,
strict: bool = False,
) -> Self: ...
@overload
def __new__(
cls,
func: Callable[[_T1, _T2, _T3, _T4, _T5], _S],
iterable: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3],
iter4: Iterable[_T4],
iter5: Iterable[_T5],
/,
*,
strict: bool = False,
) -> Self: ...
@overload
def __new__(
cls,
func: Callable[..., _S],
iterable: Iterable[Any],
iter2: Iterable[Any],
iter3: Iterable[Any],
iter4: Iterable[Any],
iter5: Iterable[Any],
iter6: Iterable[Any],
/,
*iterables: Iterable[Any],
strict: bool = False,
) -> Self: ...
else:
@overload @overload
def __new__(cls, func: Callable[[_T1], _S], iterable: Iterable[_T1], /) -> Self: ... def __new__(cls, func: Callable[[_T1], _S], iterable: Iterable[_T1], /) -> Self: ...
@overload @overload
@ -1536,6 +1605,7 @@ class map(Generic[_S]):
/, /,
*iterables: Iterable[Any], *iterables: Iterable[Any],
) -> Self: ... ) -> Self: ...
def __iter__(self) -> Self: ... def __iter__(self) -> Self: ...
def __next__(self) -> _S: ... def __next__(self) -> _S: ...

View file

@ -1,17 +1,21 @@
import _compression import sys
from _bz2 import BZ2Compressor as BZ2Compressor, BZ2Decompressor as BZ2Decompressor from _bz2 import BZ2Compressor as BZ2Compressor, BZ2Decompressor as BZ2Decompressor
from _compression import BaseStream
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
from collections.abc import Iterable from collections.abc import Iterable
from typing import IO, Literal, Protocol, SupportsIndex, TextIO, overload from typing import IO, Literal, Protocol, SupportsIndex, TextIO, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 14):
from compression._common._streams import BaseStream, _Reader
else:
from _compression import BaseStream, _Reader
__all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress", "decompress"] __all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress", "decompress"]
# The following attributes and methods are optional: # The following attributes and methods are optional:
# def fileno(self) -> int: ... # def fileno(self) -> int: ...
# def close(self) -> object: ... # def close(self) -> object: ...
class _ReadableFileobj(_compression._Reader, Protocol): ... class _ReadableFileobj(_Reader, Protocol): ...
class _WritableFileobj(Protocol): class _WritableFileobj(Protocol):
def write(self, b: bytes, /) -> object: ... def write(self, b: bytes, /) -> object: ...

View file

@ -1,5 +1,5 @@
import sys import sys
from codeop import CommandCompiler from codeop import CommandCompiler, compile_command as compile_command
from collections.abc import Callable from collections.abc import Callable
from types import CodeType from types import CodeType
from typing import Any from typing import Any
@ -52,5 +52,3 @@ else:
local: dict[str, Any] | None = None, local: dict[str, Any] | None = None,
exitmsg: str | None = None, exitmsg: str | None = None,
) -> None: ... ) -> None: ...
def compile_command(source: str, filename: str = "<input>", symbol: str = "single") -> CodeType | None: ...

View file

@ -3,7 +3,11 @@ from types import CodeType
__all__ = ["compile_command", "Compile", "CommandCompiler"] __all__ = ["compile_command", "Compile", "CommandCompiler"]
def compile_command(source: str, filename: str = "<input>", symbol: str = "single") -> CodeType | None: ... if sys.version_info >= (3, 14):
def compile_command(source: str, filename: str = "<input>", symbol: str = "single", flags: int = 0) -> CodeType | None: ...
else:
def compile_command(source: str, filename: str = "<input>", symbol: str = "single") -> CodeType | None: ...
class Compile: class Compile:
flags: int flags: int

View file

@ -0,0 +1,25 @@
from _typeshed import Incomplete, WriteableBuffer
from collections.abc import Callable
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
from typing import Any, Protocol
BUFFER_SIZE = DEFAULT_BUFFER_SIZE
class _Reader(Protocol):
def read(self, n: int, /) -> bytes: ...
def seekable(self) -> bool: ...
def seek(self, n: int, /) -> Any: ...
class BaseStream(BufferedIOBase): ...
class DecompressReader(RawIOBase):
def __init__(
self,
fp: _Reader,
decomp_factory: Callable[..., Incomplete], # Consider backporting changes to _compression
trailing_error: type[Exception] | tuple[type[Exception], ...] = (),
**decomp_args: Any, # These are passed to decomp_factory.
) -> None: ...
def readinto(self, b: WriteableBuffer) -> int: ...
def read(self, size: int = -1) -> bytes: ...
def seek(self, offset: int, whence: int = 0) -> int: ...

View file

@ -0,0 +1 @@
from bz2 import *

View file

@ -0,0 +1 @@
from gzip import *

View file

@ -0,0 +1 @@
from lzma import *

View file

@ -0,0 +1 @@
from zlib import *

View file

@ -16,7 +16,27 @@ from ._base import (
from .process import ProcessPoolExecutor as ProcessPoolExecutor from .process import ProcessPoolExecutor as ProcessPoolExecutor
from .thread import ThreadPoolExecutor as ThreadPoolExecutor from .thread import ThreadPoolExecutor as ThreadPoolExecutor
if sys.version_info >= (3, 13): if sys.version_info >= (3, 14):
from .interpreter import InterpreterPoolExecutor as InterpreterPoolExecutor
__all__ = (
"FIRST_COMPLETED",
"FIRST_EXCEPTION",
"ALL_COMPLETED",
"CancelledError",
"TimeoutError",
"InvalidStateError",
"BrokenExecutor",
"Future",
"Executor",
"wait",
"as_completed",
"ProcessPoolExecutor",
"ThreadPoolExecutor",
"InterpreterPoolExecutor",
)
elif sys.version_info >= (3, 13):
__all__ = ( __all__ = (
"FIRST_COMPLETED", "FIRST_COMPLETED",
"FIRST_EXCEPTION", "FIRST_EXCEPTION",

View file

@ -54,9 +54,20 @@ class Future(Generic[_T]):
class Executor: class Executor:
def submit(self, fn: Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Future[_T]: ... def submit(self, fn: Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Future[_T]: ...
if sys.version_info >= (3, 14):
def map(
self,
fn: Callable[..., _T],
*iterables: Iterable[Any],
timeout: float | None = None,
chunksize: int = 1,
buffersize: int | None = None,
) -> Iterator[_T]: ...
else:
def map( def map(
self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: float | None = None, chunksize: int = 1 self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: float | None = None, chunksize: int = 1
) -> Iterator[_T]: ... ) -> Iterator[_T]: ...
def shutdown(self, wait: bool = True, *, cancel_futures: bool = False) -> None: ... def shutdown(self, wait: bool = True, *, cancel_futures: bool = False) -> None: ...
def __enter__(self) -> Self: ... def __enter__(self) -> Self: ...
def __exit__( def __exit__(

View file

@ -0,0 +1,102 @@
import sys
from collections.abc import Callable, Mapping
from concurrent.futures import ThreadPoolExecutor
from typing import Final, Literal, Protocol, overload, type_check_only
from typing_extensions import ParamSpec, Self, TypeAlias, TypeVar, TypeVarTuple, Unpack
_Task: TypeAlias = tuple[bytes, Literal["function", "script"]]
@type_check_only
class _TaskFunc(Protocol):
@overload
def __call__(self, fn: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> tuple[bytes, Literal["function"]]: ...
@overload
def __call__(self, fn: str) -> tuple[bytes, Literal["script"]]: ...
_Ts = TypeVarTuple("_Ts")
_P = ParamSpec("_P")
_R = TypeVar("_R")
# A `type.simplenamespace` with `__name__` attribute.
@type_check_only
class _HasName(Protocol):
__name__: str
# `_interpreters.exec` technically gives us a simple namespace.
@type_check_only
class _ExcInfo(Protocol):
formatted: str
msg: str
type: _HasName
if sys.version_info >= (3, 14):
from concurrent.futures.thread import BrokenThreadPool, WorkerContext as ThreadWorkerContext
from _interpreters import InterpreterError
class ExecutionFailed(InterpreterError):
def __init__(self, excinfo: _ExcInfo) -> None: ... # type: ignore[override]
UNBOUND: Final = 2
class WorkerContext(ThreadWorkerContext):
# Parent class doesn't have `shared` argument,
@overload # type: ignore[override]
@classmethod
def prepare(
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]], shared: Mapping[str, object]
) -> tuple[Callable[[], Self], _TaskFunc]: ...
@overload # type: ignore[override]
@classmethod
def prepare(
cls, initializer: Callable[[], object], initargs: tuple[()], shared: Mapping[str, object]
) -> tuple[Callable[[], Self], _TaskFunc]: ...
def __init__(
self, initdata: tuple[bytes, Literal["function", "script"]], shared: Mapping[str, object] | None = None
) -> None: ... # type: ignore[override]
def __del__(self) -> None: ...
def run(self, task: _Task) -> None: ... # type: ignore[override]
class BrokenInterpreterPool(BrokenThreadPool): ...
class InterpreterPoolExecutor(ThreadPoolExecutor):
BROKEN: type[BrokenInterpreterPool]
@overload # type: ignore[override]
@classmethod
def prepare_context(
cls, initializer: Callable[[], object], initargs: tuple[()], shared: Mapping[str, object]
) -> tuple[Callable[[], WorkerContext], _TaskFunc]: ...
@overload # type: ignore[override]
@classmethod
def prepare_context(
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]], shared: Mapping[str, object]
) -> tuple[Callable[[], WorkerContext], _TaskFunc]: ...
@overload
def __init__(
self,
max_workers: int | None = None,
thread_name_prefix: str = "",
initializer: Callable[[], object] | None = None,
initargs: tuple[()] = (),
shared: Mapping[str, object] | None = None,
) -> None: ...
@overload
def __init__(
self,
max_workers: int | None = None,
thread_name_prefix: str = "",
*,
initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]],
shared: Mapping[str, object] | None = None,
) -> None: ...
@overload
def __init__(
self,
max_workers: int | None,
thread_name_prefix: str,
initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]],
shared: Mapping[str, object] | None = None,
) -> None: ...

View file

@ -236,3 +236,7 @@ class ProcessPoolExecutor(Executor):
def _start_executor_manager_thread(self) -> None: ... def _start_executor_manager_thread(self) -> None: ...
def _adjust_process_count(self) -> None: ... def _adjust_process_count(self) -> None: ...
if sys.version_info >= (3, 14):
def kill_workers(self) -> None: ...
def terminate_workers(self) -> None: ...

View file

@ -1,9 +1,10 @@
import queue import queue
import sys
from collections.abc import Callable, Iterable, Mapping, Set as AbstractSet from collections.abc import Callable, Iterable, Mapping, Set as AbstractSet
from threading import Lock, Semaphore, Thread from threading import Lock, Semaphore, Thread
from types import GenericAlias from types import GenericAlias
from typing import Any, Generic, TypeVar, overload from typing import Any, Generic, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeVarTuple, Unpack from typing_extensions import Self, TypeAlias, TypeVarTuple, Unpack
from weakref import ref from weakref import ref
from ._base import BrokenExecutor, Executor, Future from ._base import BrokenExecutor, Executor, Future
@ -18,7 +19,50 @@ def _python_exit() -> None: ...
_S = TypeVar("_S") _S = TypeVar("_S")
class _WorkItem(Generic[_S]): _Task: TypeAlias = tuple[Callable[..., Any], tuple[Any, ...], dict[str, Any]]
_C = TypeVar("_C", bound=Callable[..., object])
_KT = TypeVar("_KT", bound=str)
_VT = TypeVar("_VT")
@type_check_only
class _ResolveTaskFunc(Protocol):
def __call__(
self, func: _C, args: tuple[Unpack[_Ts]], kwargs: dict[_KT, _VT]
) -> tuple[_C, tuple[Unpack[_Ts]], dict[_KT, _VT]]: ...
if sys.version_info >= (3, 14):
class WorkerContext:
@overload
@classmethod
def prepare(
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]
) -> tuple[Callable[[], Self], _ResolveTaskFunc]: ...
@overload
@classmethod
def prepare(
cls, initializer: Callable[[], object], initargs: tuple[()]
) -> tuple[Callable[[], Self], _ResolveTaskFunc]: ...
@overload
def __init__(self, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]) -> None: ...
@overload
def __init__(self, initializer: Callable[[], object], initargs: tuple[()]) -> None: ...
def initialize(self) -> None: ...
def finalize(self) -> None: ...
def run(self, task: _Task) -> None: ...
if sys.version_info >= (3, 14):
class _WorkItem(Generic[_S]):
future: Future[Any]
task: _Task
def __init__(self, future: Future[Any], task: _Task) -> None: ...
def run(self, ctx: WorkerContext) -> None: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def _worker(executor_reference: ref[Any], ctx: WorkerContext, work_queue: queue.SimpleQueue[Any]) -> None: ...
else:
class _WorkItem(Generic[_S]):
future: Future[_S] future: Future[_S]
fn: Callable[..., _S] fn: Callable[..., _S]
args: Iterable[Any] args: Iterable[Any]
@ -27,16 +71,19 @@ class _WorkItem(Generic[_S]):
def run(self) -> None: ... def run(self) -> None: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def _worker( def _worker(
executor_reference: ref[Any], executor_reference: ref[Any],
work_queue: queue.SimpleQueue[Any], work_queue: queue.SimpleQueue[Any],
initializer: Callable[[Unpack[_Ts]], object], initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]], initargs: tuple[Unpack[_Ts]],
) -> None: ... ) -> None: ...
class BrokenThreadPool(BrokenExecutor): ... class BrokenThreadPool(BrokenExecutor): ...
class ThreadPoolExecutor(Executor): class ThreadPoolExecutor(Executor):
if sys.version_info >= (3, 14):
BROKEN: type[BrokenThreadPool]
_max_workers: int _max_workers: int
_idle_semaphore: Semaphore _idle_semaphore: Semaphore
_threads: AbstractSet[Thread] _threads: AbstractSet[Thread]
@ -47,6 +94,19 @@ class ThreadPoolExecutor(Executor):
_initializer: Callable[..., None] | None _initializer: Callable[..., None] | None
_initargs: tuple[Any, ...] _initargs: tuple[Any, ...]
_work_queue: queue.SimpleQueue[_WorkItem[Any]] _work_queue: queue.SimpleQueue[_WorkItem[Any]]
if sys.version_info >= (3, 14):
@overload
@classmethod
def prepare_context(
cls, initializer: Callable[[], object], initargs: tuple[()]
) -> tuple[Callable[[], Self], _ResolveTaskFunc]: ...
@overload
@classmethod
def prepare_context(
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]
) -> tuple[Callable[[], Self], _ResolveTaskFunc]: ...
@overload @overload
def __init__( def __init__(
self, self,

View file

@ -5,7 +5,33 @@ from re import Pattern
from typing import Any, ClassVar, Final, Literal, TypeVar, overload from typing import Any, ClassVar, Final, Literal, TypeVar, overload
from typing_extensions import TypeAlias from typing_extensions import TypeAlias
if sys.version_info >= (3, 13): if sys.version_info >= (3, 14):
__all__ = (
"NoSectionError",
"DuplicateOptionError",
"DuplicateSectionError",
"NoOptionError",
"InterpolationError",
"InterpolationDepthError",
"InterpolationMissingOptionError",
"InterpolationSyntaxError",
"ParsingError",
"MissingSectionHeaderError",
"MultilineContinuationError",
"UnnamedSectionDisabledError",
"InvalidWriteError",
"ConfigParser",
"RawConfigParser",
"Interpolation",
"BasicInterpolation",
"ExtendedInterpolation",
"SectionProxy",
"ConverterMapping",
"DEFAULTSECT",
"MAX_INTERPOLATION_DEPTH",
"UNNAMED_SECTION",
)
elif sys.version_info >= (3, 13):
__all__ = ( __all__ = (
"NoSectionError", "NoSectionError",
"DuplicateOptionError", "DuplicateOptionError",
@ -429,3 +455,10 @@ if sys.version_info >= (3, 13):
lineno: int lineno: int
line: str line: str
def __init__(self, filename: str, lineno: int, line: str) -> None: ... def __init__(self, filename: str, lineno: int, line: str) -> None: ...
if sys.version_info >= (3, 14):
class UnnamedSectionDisabledError(Error):
msg: Final = "Support for UNNAMED_SECTION is disabled."
def __init__(self) -> None: ...
class InvalidWriteError(Error): ...

View file

@ -1,6 +1,5 @@
import sys import sys
from _ctypes import ( from _ctypes import (
POINTER as POINTER,
RTLD_GLOBAL as RTLD_GLOBAL, RTLD_GLOBAL as RTLD_GLOBAL,
RTLD_LOCAL as RTLD_LOCAL, RTLD_LOCAL as RTLD_LOCAL,
Array as Array, Array as Array,
@ -19,7 +18,6 @@ from _ctypes import (
alignment as alignment, alignment as alignment,
byref as byref, byref as byref,
get_errno as get_errno, get_errno as get_errno,
pointer as pointer,
resize as resize, resize as resize,
set_errno as set_errno, set_errno as set_errno,
sizeof as sizeof, sizeof as sizeof,
@ -27,7 +25,7 @@ from _ctypes import (
from _typeshed import StrPath from _typeshed import StrPath
from ctypes._endian import BigEndianStructure as BigEndianStructure, LittleEndianStructure as LittleEndianStructure from ctypes._endian import BigEndianStructure as BigEndianStructure, LittleEndianStructure as LittleEndianStructure
from types import GenericAlias from types import GenericAlias
from typing import Any, ClassVar, Generic, Literal, TypeVar, type_check_only from typing import Any, ClassVar, Generic, Literal, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias, deprecated from typing_extensions import Self, TypeAlias, deprecated
if sys.platform == "win32": if sys.platform == "win32":
@ -36,9 +34,22 @@ if sys.platform == "win32":
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
from ctypes._endian import BigEndianUnion as BigEndianUnion, LittleEndianUnion as LittleEndianUnion from ctypes._endian import BigEndianUnion as BigEndianUnion, LittleEndianUnion as LittleEndianUnion
_CT = TypeVar("_CT", bound=_CData)
_T = TypeVar("_T", default=Any) _T = TypeVar("_T", default=Any)
_DLLT = TypeVar("_DLLT", bound=CDLL) _DLLT = TypeVar("_DLLT", bound=CDLL)
_CT = TypeVar("_CT", bound=_CData)
if sys.version_info >= (3, 14):
@overload
@deprecated("ctypes.POINTER with string")
def POINTER(cls: str) -> type[Any]: ...
@overload
def POINTER(cls: None) -> type[c_void_p]: ...
@overload
def POINTER(cls: type[_CT]) -> type[_Pointer[_CT]]: ...
def pointer(obj: _CT) -> _Pointer[_CT]: ...
else:
from _ctypes import POINTER as POINTER, pointer as pointer
DEFAULT_MODE: int DEFAULT_MODE: int
@ -148,7 +159,7 @@ c_buffer = create_string_buffer
def create_unicode_buffer(init: int | str, size: int | None = None) -> Array[c_wchar]: ... def create_unicode_buffer(init: int | str, size: int | None = None) -> Array[c_wchar]: ...
@deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15") @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15")
def SetPointerType(pointer: type[_Pointer[Any]], cls: Any) -> None: ... # noqa: F811 def SetPointerType(pointer: type[_Pointer[Any]], cls: Any) -> None: ...
def ARRAY(typ: _CT, len: int) -> Array[_CT]: ... # Soft Deprecated, no plans to remove def ARRAY(typ: _CT, len: int) -> Array[_CT]: ... # Soft Deprecated, no plans to remove
if sys.platform == "win32": if sys.platform == "win32":

View file

@ -5,7 +5,7 @@ from _typeshed import DataclassInstance
from builtins import type as Type # alias to avoid name clashes with fields named "type" from builtins import type as Type # alias to avoid name clashes with fields named "type"
from collections.abc import Callable, Iterable, Mapping from collections.abc import Callable, Iterable, Mapping
from types import GenericAlias from types import GenericAlias
from typing import Any, Generic, Literal, Protocol, TypeVar, overload from typing import Any, Generic, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Never, TypeIs from typing_extensions import Never, TypeIs
_T = TypeVar("_T") _T = TypeVar("_T")
@ -31,6 +31,25 @@ if sys.version_info >= (3, 10):
_DataclassT = TypeVar("_DataclassT", bound=DataclassInstance) _DataclassT = TypeVar("_DataclassT", bound=DataclassInstance)
@type_check_only
class _DataclassFactory(Protocol):
def __call__(
self,
cls: type[_T],
/,
*,
init: bool = True,
repr: bool = True,
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
match_args: bool = True,
kw_only: bool = False,
slots: bool = False,
weakref_slot: bool = False,
) -> type[_T]: ...
# define _MISSING_TYPE as an enum within the type stubs, # define _MISSING_TYPE as an enum within the type stubs,
# even though that is not really its type at runtime # even though that is not really its type at runtime
# this allows us to use Literal[_MISSING_TYPE.MISSING] # this allows us to use Literal[_MISSING_TYPE.MISSING]
@ -114,8 +133,27 @@ class Field(Generic[_T]):
init: bool init: bool
compare: bool compare: bool
metadata: types.MappingProxyType[Any, Any] metadata: types.MappingProxyType[Any, Any]
if sys.version_info >= (3, 14):
doc: str | None
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
kw_only: bool | Literal[_MISSING_TYPE.MISSING] kw_only: bool | Literal[_MISSING_TYPE.MISSING]
if sys.version_info >= (3, 14):
def __init__(
self,
default: _T,
default_factory: Callable[[], _T],
init: bool,
repr: bool,
hash: bool | None,
compare: bool,
metadata: Mapping[Any, Any],
kw_only: bool,
doc: str | None,
) -> None: ...
elif sys.version_info >= (3, 10):
def __init__( def __init__(
self, self,
default: _T, default: _T,
@ -144,7 +182,48 @@ class Field(Generic[_T]):
# NOTE: Actual return type is 'Field[_T]', but we want to help type checkers # NOTE: Actual return type is 'Field[_T]', but we want to help type checkers
# to understand the magic that happens at runtime. # to understand the magic that happens at runtime.
if sys.version_info >= (3, 10): if sys.version_info >= (3, 14):
@overload # `default` and `default_factory` are optional and mutually exclusive.
def field(
*,
default: _T,
default_factory: Literal[_MISSING_TYPE.MISSING] = ...,
init: bool = True,
repr: bool = True,
hash: bool | None = None,
compare: bool = True,
metadata: Mapping[Any, Any] | None = None,
kw_only: bool | Literal[_MISSING_TYPE.MISSING] = ...,
doc: str | None = None,
) -> _T: ...
@overload
def field(
*,
default: Literal[_MISSING_TYPE.MISSING] = ...,
default_factory: Callable[[], _T],
init: bool = True,
repr: bool = True,
hash: bool | None = None,
compare: bool = True,
metadata: Mapping[Any, Any] | None = None,
kw_only: bool | Literal[_MISSING_TYPE.MISSING] = ...,
doc: str | None = None,
) -> _T: ...
@overload
def field(
*,
default: Literal[_MISSING_TYPE.MISSING] = ...,
default_factory: Literal[_MISSING_TYPE.MISSING] = ...,
init: bool = True,
repr: bool = True,
hash: bool | None = None,
compare: bool = True,
metadata: Mapping[Any, Any] | None = None,
kw_only: bool | Literal[_MISSING_TYPE.MISSING] = ...,
doc: str | None = None,
) -> Any: ...
elif sys.version_info >= (3, 10):
@overload # `default` and `default_factory` are optional and mutually exclusive. @overload # `default` and `default_factory` are optional and mutually exclusive.
def field( def field(
*, *,
@ -237,7 +316,28 @@ class InitVar(Generic[_T], metaclass=type):
@overload @overload
def __class_getitem__(cls, type: Any) -> InitVar[Any]: ... # pyright: ignore[reportInvalidTypeForm] def __class_getitem__(cls, type: Any) -> InitVar[Any]: ... # pyright: ignore[reportInvalidTypeForm]
if sys.version_info >= (3, 12): if sys.version_info >= (3, 14):
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]],
*,
bases: tuple[type, ...] = (),
namespace: dict[str, Any] | None = None,
init: bool = True,
repr: bool = True,
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
match_args: bool = True,
kw_only: bool = False,
slots: bool = False,
weakref_slot: bool = False,
module: str | None = None,
decorator: _DataclassFactory = ...,
) -> type: ...
elif sys.version_info >= (3, 12):
def make_dataclass( def make_dataclass(
cls_name: str, cls_name: str,
fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]], fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]],

View file

@ -73,6 +73,11 @@ class date:
@property @property
def day(self) -> int: ... def day(self) -> int: ...
def ctime(self) -> str: ... def ctime(self) -> str: ...
if sys.version_info >= (3, 14):
@classmethod
def strptime(cls, date_string: str, format: str, /) -> Self: ...
# On <3.12, the name of the parameter in the pure-Python implementation # On <3.12, the name of the parameter in the pure-Python implementation
# didn't match the name in the C implementation, # didn't match the name in the C implementation,
# meaning it is only *safe* to pass it as a keyword argument on 3.12+ # meaning it is only *safe* to pass it as a keyword argument on 3.12+
@ -142,6 +147,11 @@ class time:
def isoformat(self, timespec: str = ...) -> str: ... def isoformat(self, timespec: str = ...) -> str: ...
@classmethod @classmethod
def fromisoformat(cls, time_string: str, /) -> Self: ... def fromisoformat(cls, time_string: str, /) -> Self: ...
if sys.version_info >= (3, 14):
@classmethod
def strptime(cls, date_string: str, format: str, /) -> Self: ...
# On <3.12, the name of the parameter in the pure-Python implementation # On <3.12, the name of the parameter in the pure-Python implementation
# didn't match the name in the C implementation, # didn't match the name in the C implementation,
# meaning it is only *safe* to pass it as a keyword argument on 3.12+ # meaning it is only *safe* to pass it as a keyword argument on 3.12+

View file

@ -1,4 +1,5 @@
import numbers import numbers
import sys
from _decimal import ( from _decimal import (
HAVE_CONTEXTVAR as HAVE_CONTEXTVAR, HAVE_CONTEXTVAR as HAVE_CONTEXTVAR,
HAVE_THREADS as HAVE_THREADS, HAVE_THREADS as HAVE_THREADS,
@ -28,6 +29,9 @@ from types import TracebackType
from typing import Any, ClassVar, Literal, NamedTuple, final, overload, type_check_only from typing import Any, ClassVar, Literal, NamedTuple, final, overload, type_check_only
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 14):
from _decimal import IEEE_CONTEXT_MAX_BITS as IEEE_CONTEXT_MAX_BITS, IEEEContext as IEEEContext
_Decimal: TypeAlias = Decimal | int _Decimal: TypeAlias = Decimal | int
_DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int] _DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int]
_ComparableNum: TypeAlias = Decimal | float | numbers.Rational _ComparableNum: TypeAlias = Decimal | float | numbers.Rational
@ -66,6 +70,10 @@ class FloatOperation(DecimalException, TypeError): ...
class Decimal: class Decimal:
def __new__(cls, value: _DecimalNew = "0", context: Context | None = None) -> Self: ... def __new__(cls, value: _DecimalNew = "0", context: Context | None = None) -> Self: ...
if sys.version_info >= (3, 14):
@classmethod
def from_number(cls, number: Decimal | float, /) -> Self: ...
@classmethod @classmethod
def from_float(cls, f: float, /) -> Self: ... def from_float(cls, f: float, /) -> Self: ...
def __bool__(self) -> bool: ... def __bool__(self) -> bool: ...

View file

@ -106,11 +106,40 @@ class Instruction(_Instruction):
def jump_target(self) -> int: ... def jump_target(self) -> int: ...
@property @property
def is_jump_target(self) -> bool: ... def is_jump_target(self) -> bool: ...
if sys.version_info >= (3, 14):
@staticmethod
def make(
opname: str,
arg: int | None,
argval: Any,
argrepr: str,
offset: int,
start_offset: int,
starts_line: bool,
line_number: int | None,
label: int | None = None,
positions: Positions | None = None,
cache_info: list[tuple[str, int, Any]] | None = None,
) -> Instruction: ...
class Bytecode: class Bytecode:
codeobj: types.CodeType codeobj: types.CodeType
first_line: int first_line: int
if sys.version_info >= (3, 13): if sys.version_info >= (3, 14):
show_positions: bool
# 3.14 added `show_positions`
def __init__(
self,
x: _HaveCodeType | str,
*,
first_line: int | None = None,
current_offset: int | None = None,
show_caches: bool = False,
adaptive: bool = False,
show_offsets: bool = False,
show_positions: bool = False,
) -> None: ...
elif sys.version_info >= (3, 13):
show_offsets: bool show_offsets: bool
# 3.13 added `show_offsets` # 3.13 added `show_offsets`
def __init__( def __init__(
@ -156,7 +185,39 @@ def findlinestarts(code: _HaveCodeType) -> Iterator[tuple[int, int]]: ...
def pretty_flags(flags: int) -> str: ... def pretty_flags(flags: int) -> str: ...
def code_info(x: _HaveCodeType | str) -> str: ... def code_info(x: _HaveCodeType | str) -> str: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 14):
# 3.14 added `show_positions`
def dis(
x: _HaveCodeType | str | bytes | bytearray | None = None,
*,
file: IO[str] | None = None,
depth: int | None = None,
show_caches: bool = False,
adaptive: bool = False,
show_offsets: bool = False,
show_positions: bool = False,
) -> None: ...
def disassemble(
co: _HaveCodeType,
lasti: int = -1,
*,
file: IO[str] | None = None,
show_caches: bool = False,
adaptive: bool = False,
show_offsets: bool = False,
show_positions: bool = False,
) -> None: ...
def distb(
tb: types.TracebackType | None = None,
*,
file: IO[str] | None = None,
show_caches: bool = False,
adaptive: bool = False,
show_offsets: bool = False,
show_positions: bool = False,
) -> None: ...
elif sys.version_info >= (3, 13):
# 3.13 added `show_offsets` # 3.13 added `show_offsets`
def dis( def dis(
x: _HaveCodeType | str | bytes | bytearray | None = None, x: _HaveCodeType | str | bytes | bytearray | None = None,
@ -184,10 +245,6 @@ if sys.version_info >= (3, 13):
adaptive: bool = False, adaptive: bool = False,
show_offsets: bool = False, show_offsets: bool = False,
) -> None: ... ) -> None: ...
# 3.13 made `show_cache` `None` by default
def get_instructions(
x: _HaveCodeType, *, first_line: int | None = None, show_caches: bool | None = None, adaptive: bool = False
) -> Iterator[Instruction]: ...
elif sys.version_info >= (3, 11): elif sys.version_info >= (3, 11):
# 3.11 added `show_caches` and `adaptive` # 3.11 added `show_caches` and `adaptive`
@ -205,9 +262,6 @@ elif sys.version_info >= (3, 11):
def distb( def distb(
tb: types.TracebackType | None = None, *, file: IO[str] | None = None, show_caches: bool = False, adaptive: bool = False tb: types.TracebackType | None = None, *, file: IO[str] | None = None, show_caches: bool = False, adaptive: bool = False
) -> None: ... ) -> None: ...
def get_instructions(
x: _HaveCodeType, *, first_line: int | None = None, show_caches: bool = False, adaptive: bool = False
) -> Iterator[Instruction]: ...
else: else:
def dis( def dis(
@ -215,6 +269,19 @@ else:
) -> None: ... ) -> None: ...
def disassemble(co: _HaveCodeType, lasti: int = -1, *, file: IO[str] | None = None) -> None: ... def disassemble(co: _HaveCodeType, lasti: int = -1, *, file: IO[str] | None = None) -> None: ...
def distb(tb: types.TracebackType | None = None, *, file: IO[str] | None = None) -> None: ... def distb(tb: types.TracebackType | None = None, *, file: IO[str] | None = None) -> None: ...
if sys.version_info >= (3, 13):
# 3.13 made `show_cache` `None` by default
def get_instructions(
x: _HaveCodeType, *, first_line: int | None = None, show_caches: bool | None = None, adaptive: bool = False
) -> Iterator[Instruction]: ...
elif sys.version_info >= (3, 11):
def get_instructions(
x: _HaveCodeType, *, first_line: int | None = None, show_caches: bool = False, adaptive: bool = False
) -> Iterator[Instruction]: ...
else:
def get_instructions(x: _HaveCodeType, *, first_line: int | None = None) -> Iterator[Instruction]: ... def get_instructions(x: _HaveCodeType, *, first_line: int | None = None) -> Iterator[Instruction]: ...
def show_code(co: _HaveCodeType, *, file: IO[str] | None = None) -> None: ... def show_code(co: _HaveCodeType, *, file: IO[str] | None = None) -> None: ...

View file

@ -1,6 +1,7 @@
from collections.abc import Callable from collections.abc import Callable
from email._policybase import _MessageT
from email.message import Message from email.message import Message
from email.policy import Policy, _MessageT from email.policy import Policy
from typing import IO, overload from typing import IO, overload
from typing_extensions import TypeAlias from typing_extensions import TypeAlias

View file

@ -2,12 +2,13 @@ from abc import ABCMeta, abstractmethod
from email.errors import MessageDefect from email.errors import MessageDefect
from email.header import Header from email.header import Header
from email.message import Message from email.message import Message
from typing import Generic, Protocol, TypeVar, type_check_only from typing import Any, Generic, Protocol, TypeVar, type_check_only
from typing_extensions import Self from typing_extensions import Self
__all__ = ["Policy", "Compat32", "compat32"] __all__ = ["Policy", "Compat32", "compat32"]
_MessageT = TypeVar("_MessageT", bound=Message, default=Message) _MessageT = TypeVar("_MessageT", bound=Message[Any, Any], default=Message[str, str])
_MessageT_co = TypeVar("_MessageT_co", covariant=True, bound=Message[Any, Any], default=Message[str, str])
@type_check_only @type_check_only
class _MessageFactory(Protocol[_MessageT]): class _MessageFactory(Protocol[_MessageT]):
@ -16,13 +17,13 @@ class _MessageFactory(Protocol[_MessageT]):
# Policy below is the only known direct subclass of _PolicyBase. We therefore # Policy below is the only known direct subclass of _PolicyBase. We therefore
# assume that the __init__ arguments and attributes of _PolicyBase are # assume that the __init__ arguments and attributes of _PolicyBase are
# the same as those of Policy. # the same as those of Policy.
class _PolicyBase(Generic[_MessageT]): class _PolicyBase(Generic[_MessageT_co]):
max_line_length: int | None max_line_length: int | None
linesep: str linesep: str
cte_type: str cte_type: str
raise_on_defect: bool raise_on_defect: bool
mangle_from_: bool mangle_from_: bool
message_factory: _MessageFactory[_MessageT] | None message_factory: _MessageFactory[_MessageT_co] | None
# Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5 # Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool verify_generated_headers: bool
@ -34,7 +35,7 @@ class _PolicyBase(Generic[_MessageT]):
cte_type: str = "8bit", cte_type: str = "8bit",
raise_on_defect: bool = False, raise_on_defect: bool = False,
mangle_from_: bool = ..., # default depends on sub-class mangle_from_: bool = ..., # default depends on sub-class
message_factory: _MessageFactory[_MessageT] | None = None, message_factory: _MessageFactory[_MessageT_co] | None = None,
# Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5 # Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool = True, verify_generated_headers: bool = True,
) -> None: ... ) -> None: ...
@ -46,15 +47,17 @@ class _PolicyBase(Generic[_MessageT]):
cte_type: str = ..., cte_type: str = ...,
raise_on_defect: bool = ..., raise_on_defect: bool = ...,
mangle_from_: bool = ..., mangle_from_: bool = ...,
message_factory: _MessageFactory[_MessageT] | None = ..., message_factory: _MessageFactory[_MessageT_co] | None = ...,
# Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5 # Added in Python 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool = ..., verify_generated_headers: bool = ...,
) -> Self: ... ) -> Self: ...
def __add__(self, other: Policy) -> Self: ... def __add__(self, other: Policy) -> Self: ...
class Policy(_PolicyBase[_MessageT], metaclass=ABCMeta): class Policy(_PolicyBase[_MessageT_co], metaclass=ABCMeta):
def handle_defect(self, obj: _MessageT, defect: MessageDefect) -> None: ... # Every Message object has a `defects` attribute, so the following
def register_defect(self, obj: _MessageT, defect: MessageDefect) -> None: ... # methods will work for any Message object.
def handle_defect(self, obj: Message[Any, Any], defect: MessageDefect) -> None: ...
def register_defect(self, obj: Message[Any, Any], defect: MessageDefect) -> None: ...
def header_max_count(self, name: str) -> int | None: ... def header_max_count(self, name: str) -> int | None: ...
@abstractmethod @abstractmethod
def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ... def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ...
@ -67,11 +70,11 @@ class Policy(_PolicyBase[_MessageT], metaclass=ABCMeta):
@abstractmethod @abstractmethod
def fold_binary(self, name: str, value: str) -> bytes: ... def fold_binary(self, name: str, value: str) -> bytes: ...
class Compat32(Policy[_MessageT]): class Compat32(Policy[_MessageT_co]):
def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ... def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ...
def header_store_parse(self, name: str, value: str) -> tuple[str, str]: ... def header_store_parse(self, name: str, value: str) -> tuple[str, str]: ...
def header_fetch_parse(self, name: str, value: str) -> str | Header: ... # type: ignore[override] def header_fetch_parse(self, name: str, value: str) -> str | Header: ... # type: ignore[override]
def fold(self, name: str, value: str) -> str: ... def fold(self, name: str, value: str) -> str: ...
def fold_binary(self, name: str, value: str) -> bytes: ... def fold_binary(self, name: str, value: str) -> bytes: ...
compat32: Compat32[Message] compat32: Compat32[Message[str, str]]

View file

@ -1,12 +1,11 @@
from collections.abc import Callable from collections.abc import Callable
from email._policybase import _MessageT
from email.message import Message from email.message import Message
from email.policy import Policy from email.policy import Policy
from typing import Generic, TypeVar, overload from typing import Generic, overload
__all__ = ["FeedParser", "BytesFeedParser"] __all__ = ["FeedParser", "BytesFeedParser"]
_MessageT = TypeVar("_MessageT", bound=Message, default=Message)
class FeedParser(Generic[_MessageT]): class FeedParser(Generic[_MessageT]):
@overload @overload
def __init__(self: FeedParser[Message], _factory: None = None, *, policy: Policy[Message] = ...) -> None: ... def __init__(self: FeedParser[Message], _factory: None = None, *, policy: Policy[Message] = ...) -> None: ...

View file

@ -7,7 +7,7 @@ from typing_extensions import Self
__all__ = ["Generator", "DecodedGenerator", "BytesGenerator"] __all__ = ["Generator", "DecodedGenerator", "BytesGenerator"]
# By default, generators do not have a message policy. # By default, generators do not have a message policy.
_MessageT = TypeVar("_MessageT", bound=Message, default=Any) _MessageT = TypeVar("_MessageT", bound=Message[Any, Any], default=Any)
class Generator(Generic[_MessageT]): class Generator(Generic[_MessageT]):
maxheaderlen: int | None maxheaderlen: int | None

View file

@ -12,12 +12,12 @@ __all__ = ["Message", "EmailMessage"]
_T = TypeVar("_T") _T = TypeVar("_T")
# Type returned by Policy.header_fetch_parse, often str or Header. # Type returned by Policy.header_fetch_parse, often str or Header.
_HeaderT = TypeVar("_HeaderT", default=str) _HeaderT_co = TypeVar("_HeaderT_co", covariant=True, default=str)
_HeaderParamT = TypeVar("_HeaderParamT", default=str) _HeaderParamT_contra = TypeVar("_HeaderParamT_contra", contravariant=True, default=str)
# Represents headers constructed by HeaderRegistry. Those are sub-classes # Represents headers constructed by HeaderRegistry. Those are sub-classes
# of BaseHeader and another header type. # of BaseHeader and another header type.
_HeaderRegistryT = TypeVar("_HeaderRegistryT", default=Any) _HeaderRegistryT_co = TypeVar("_HeaderRegistryT_co", covariant=True, default=Any)
_HeaderRegistryParamT = TypeVar("_HeaderRegistryParamT", default=Any) _HeaderRegistryParamT_contra = TypeVar("_HeaderRegistryParamT_contra", contravariant=True, default=Any)
_PayloadType: TypeAlias = Message | str _PayloadType: TypeAlias = Message | str
_EncodedPayloadType: TypeAlias = Message | bytes _EncodedPayloadType: TypeAlias = Message | bytes
@ -30,7 +30,7 @@ class _SupportsEncodeToPayload(Protocol):
class _SupportsDecodeToPayload(Protocol): class _SupportsDecodeToPayload(Protocol):
def decode(self, encoding: str, errors: str, /) -> _PayloadType | _MultipartPayloadType: ... def decode(self, encoding: str, errors: str, /) -> _PayloadType | _MultipartPayloadType: ...
class Message(Generic[_HeaderT, _HeaderParamT]): class Message(Generic[_HeaderT_co, _HeaderParamT_contra]):
# The policy attributes and arguments in this class and its subclasses # The policy attributes and arguments in this class and its subclasses
# would ideally use Policy[Self], but this is not possible. # would ideally use Policy[Self], but this is not possible.
policy: Policy[Any] # undocumented policy: Policy[Any] # undocumented
@ -76,22 +76,22 @@ class Message(Generic[_HeaderT, _HeaderParamT]):
# This is important for protocols using __getitem__, like SupportsKeysAndGetItem # This is important for protocols using __getitem__, like SupportsKeysAndGetItem
# Morally, the return type should be `AnyOf[_HeaderType, None]`, # Morally, the return type should be `AnyOf[_HeaderType, None]`,
# so using "the Any trick" instead. # so using "the Any trick" instead.
def __getitem__(self, name: str) -> _HeaderT | MaybeNone: ... def __getitem__(self, name: str) -> _HeaderT_co | MaybeNone: ...
def __setitem__(self, name: str, val: _HeaderParamT) -> None: ... def __setitem__(self, name: str, val: _HeaderParamT_contra) -> None: ...
def __delitem__(self, name: str) -> None: ... def __delitem__(self, name: str) -> None: ...
def keys(self) -> list[str]: ... def keys(self) -> list[str]: ...
def values(self) -> list[_HeaderT]: ... def values(self) -> list[_HeaderT_co]: ...
def items(self) -> list[tuple[str, _HeaderT]]: ... def items(self) -> list[tuple[str, _HeaderT_co]]: ...
@overload @overload
def get(self, name: str, failobj: None = None) -> _HeaderT | None: ... def get(self, name: str, failobj: None = None) -> _HeaderT_co | None: ...
@overload @overload
def get(self, name: str, failobj: _T) -> _HeaderT | _T: ... def get(self, name: str, failobj: _T) -> _HeaderT_co | _T: ...
@overload @overload
def get_all(self, name: str, failobj: None = None) -> list[_HeaderT] | None: ... def get_all(self, name: str, failobj: None = None) -> list[_HeaderT_co] | None: ...
@overload @overload
def get_all(self, name: str, failobj: _T) -> list[_HeaderT] | _T: ... def get_all(self, name: str, failobj: _T) -> list[_HeaderT_co] | _T: ...
def add_header(self, _name: str, _value: str, **_params: _ParamsType) -> None: ... def add_header(self, _name: str, _value: str, **_params: _ParamsType) -> None: ...
def replace_header(self, _name: str, _value: _HeaderParamT) -> None: ... def replace_header(self, _name: str, _value: _HeaderParamT_contra) -> None: ...
def get_content_type(self) -> str: ... def get_content_type(self) -> str: ...
def get_content_maintype(self) -> str: ... def get_content_maintype(self) -> str: ...
def get_content_subtype(self) -> str: ... def get_content_subtype(self) -> str: ...
@ -144,18 +144,18 @@ class Message(Generic[_HeaderT, _HeaderParamT]):
replace: bool = False, replace: bool = False,
) -> None: ... ) -> None: ...
# The following two methods are undocumented, but a source code comment states that they are public API # The following two methods are undocumented, but a source code comment states that they are public API
def set_raw(self, name: str, value: _HeaderParamT) -> None: ... def set_raw(self, name: str, value: _HeaderParamT_contra) -> None: ...
def raw_items(self) -> Iterator[tuple[str, _HeaderT]]: ... def raw_items(self) -> Iterator[tuple[str, _HeaderT_co]]: ...
class MIMEPart(Message[_HeaderRegistryT, _HeaderRegistryParamT]): class MIMEPart(Message[_HeaderRegistryT_co, _HeaderRegistryParamT_contra]):
def __init__(self, policy: Policy[Any] | None = None) -> None: ... def __init__(self, policy: Policy[Any] | None = None) -> None: ...
def get_body(self, preferencelist: Sequence[str] = ("related", "html", "plain")) -> MIMEPart[_HeaderRegistryT] | None: ... def get_body(self, preferencelist: Sequence[str] = ("related", "html", "plain")) -> MIMEPart[_HeaderRegistryT_co] | None: ...
def attach(self, payload: Self) -> None: ... # type: ignore[override] def attach(self, payload: Self) -> None: ... # type: ignore[override]
# The attachments are created via type(self) in the attach method. It's theoretically # The attachments are created via type(self) in the attach method. It's theoretically
# possible to sneak other attachment types into a MIMEPart instance, but could cause # possible to sneak other attachment types into a MIMEPart instance, but could cause
# cause unforseen consequences. # cause unforseen consequences.
def iter_attachments(self) -> Iterator[Self]: ... def iter_attachments(self) -> Iterator[Self]: ...
def iter_parts(self) -> Iterator[MIMEPart[_HeaderRegistryT]]: ... def iter_parts(self) -> Iterator[MIMEPart[_HeaderRegistryT_co]]: ...
def get_content(self, *args: Any, content_manager: ContentManager | None = None, **kw: Any) -> Any: ... def get_content(self, *args: Any, content_manager: ContentManager | None = None, **kw: Any) -> Any: ...
def set_content(self, *args: Any, content_manager: ContentManager | None = None, **kw: Any) -> None: ... def set_content(self, *args: Any, content_manager: ContentManager | None = None, **kw: Any) -> None: ...
def make_related(self, boundary: str | None = None) -> None: ... def make_related(self, boundary: str | None = None) -> None: ...

View file

@ -1,5 +1,6 @@
from email._policybase import _MessageT
from email.mime.nonmultipart import MIMENonMultipart from email.mime.nonmultipart import MIMENonMultipart
from email.policy import Policy, _MessageT from email.policy import Policy
__all__ = ["MIMEMessage"] __all__ = ["MIMEMessage"]

View file

@ -1,7 +1,8 @@
from collections.abc import Sequence from collections.abc import Sequence
from email import _ParamsType from email import _ParamsType
from email._policybase import _MessageT
from email.mime.base import MIMEBase from email.mime.base import MIMEBase
from email.policy import Policy, _MessageT from email.policy import Policy
__all__ = ["MIMEMultipart"] __all__ = ["MIMEMultipart"]

View file

@ -1,5 +1,5 @@
from email._policybase import Policy
from email.mime.nonmultipart import MIMENonMultipart from email.mime.nonmultipart import MIMENonMultipart
from email.policy import Policy
__all__ = ["MIMEText"] __all__ = ["MIMEText"]

View file

@ -1,20 +1,21 @@
from _typeshed import SupportsRead from _typeshed import SupportsRead
from collections.abc import Callable from collections.abc import Callable
from email._policybase import _MessageT
from email.feedparser import BytesFeedParser as BytesFeedParser, FeedParser as FeedParser from email.feedparser import BytesFeedParser as BytesFeedParser, FeedParser as FeedParser
from email.message import Message from email.message import Message
from email.policy import Policy from email.policy import Policy
from io import _WrappedBuffer from io import _WrappedBuffer
from typing import Generic, TypeVar, overload from typing import Generic, overload
__all__ = ["Parser", "HeaderParser", "BytesParser", "BytesHeaderParser", "FeedParser", "BytesFeedParser"] __all__ = ["Parser", "HeaderParser", "BytesParser", "BytesHeaderParser", "FeedParser", "BytesFeedParser"]
_MessageT = TypeVar("_MessageT", bound=Message, default=Message)
class Parser(Generic[_MessageT]): class Parser(Generic[_MessageT]):
@overload @overload
def __init__(self: Parser[Message[str, str]], _class: None = None, *, policy: Policy[Message[str, str]] = ...) -> None: ... def __init__(self: Parser[Message[str, str]], _class: None = None) -> None: ...
@overload @overload
def __init__(self, _class: Callable[[], _MessageT], *, policy: Policy[_MessageT] = ...) -> None: ... def __init__(self, _class: None = None, *, policy: Policy[_MessageT]) -> None: ...
@overload
def __init__(self, _class: Callable[[], _MessageT] | None, *, policy: Policy[_MessageT] = ...) -> None: ...
def parse(self, fp: SupportsRead[str], headersonly: bool = False) -> _MessageT: ... def parse(self, fp: SupportsRead[str], headersonly: bool = False) -> _MessageT: ...
def parsestr(self, text: str, headersonly: bool = False) -> _MessageT: ... def parsestr(self, text: str, headersonly: bool = False) -> _MessageT: ...
@ -25,9 +26,9 @@ class HeaderParser(Parser[_MessageT]):
class BytesParser(Generic[_MessageT]): class BytesParser(Generic[_MessageT]):
parser: Parser[_MessageT] parser: Parser[_MessageT]
@overload @overload
def __init__( def __init__(self: BytesParser[Message[str, str]], _class: None = None) -> None: ...
self: BytesParser[Message[str, str]], _class: None = None, *, policy: Policy[Message[str, str]] = ... @overload
) -> None: ... def __init__(self, _class: None = None, *, policy: Policy[_MessageT]) -> None: ...
@overload @overload
def __init__(self, _class: Callable[[], _MessageT], *, policy: Policy[_MessageT] = ...) -> None: ... def __init__(self, _class: Callable[[], _MessageT], *, policy: Policy[_MessageT] = ...) -> None: ...
def parse(self, fp: _WrappedBuffer, headersonly: bool = False) -> _MessageT: ... def parse(self, fp: _WrappedBuffer, headersonly: bool = False) -> _MessageT: ...

View file

@ -1,14 +1,12 @@
from collections.abc import Callable from collections.abc import Callable
from email._policybase import Compat32 as Compat32, Policy as Policy, _MessageFactory, compat32 as compat32 from email._policybase import Compat32 as Compat32, Policy as Policy, _MessageFactory, _MessageT, compat32 as compat32
from email.contentmanager import ContentManager from email.contentmanager import ContentManager
from email.message import EmailMessage, Message from email.message import EmailMessage
from typing import Any, TypeVar, overload from typing import Any, overload
from typing_extensions import Self from typing_extensions import Self
__all__ = ["Compat32", "compat32", "Policy", "EmailPolicy", "default", "strict", "SMTP", "HTTP"] __all__ = ["Compat32", "compat32", "Policy", "EmailPolicy", "default", "strict", "SMTP", "HTTP"]
_MessageT = TypeVar("_MessageT", bound=Message, default=Message)
class EmailPolicy(Policy[_MessageT]): class EmailPolicy(Policy[_MessageT]):
utf8: bool utf8: bool
refold_source: str refold_source: str

View file

@ -1,4 +1,3 @@
from _typeshed import Incomplete
from codecs import CodecInfo from codecs import CodecInfo
class CodecRegistryError(LookupError, SystemError): ... class CodecRegistryError(LookupError, SystemError): ...
@ -7,4 +6,4 @@ def normalize_encoding(encoding: str | bytes) -> str: ...
def search_function(encoding: str) -> CodecInfo | None: ... def search_function(encoding: str) -> CodecInfo | None: ...
# Needed for submodules # Needed for submodules
def __getattr__(name: str) -> Incomplete: ... def __getattr__(name: str): ... # incomplete module

View file

@ -1,9 +1,15 @@
import sys
from collections.abc import Iterable from collections.abc import Iterable
from typing import AnyStr from typing import AnyStr
__all__ = ["filter", "fnmatch", "fnmatchcase", "translate"] __all__ = ["filter", "fnmatch", "fnmatchcase", "translate"]
if sys.version_info >= (3, 14):
__all__ += ["filterfalse"]
def fnmatch(name: AnyStr, pat: AnyStr) -> bool: ... def fnmatch(name: AnyStr, pat: AnyStr) -> bool: ...
def fnmatchcase(name: AnyStr, pat: AnyStr) -> bool: ... def fnmatchcase(name: AnyStr, pat: AnyStr) -> bool: ...
def filter(names: Iterable[AnyStr], pat: AnyStr) -> list[AnyStr]: ... def filter(names: Iterable[AnyStr], pat: AnyStr) -> list[AnyStr]: ...
def translate(pat: str) -> str: ... def translate(pat: str) -> str: ...
if sys.version_info >= (3, 14):
def filterfalse(names: Iterable[AnyStr], pat: AnyStr) -> list[AnyStr]: ...

View file

@ -3,7 +3,7 @@ import types
from _typeshed import SupportsAllComparisons, SupportsItems from _typeshed import SupportsAllComparisons, SupportsItems
from collections.abc import Callable, Hashable, Iterable, Sized from collections.abc import Callable, Hashable, Iterable, Sized
from types import GenericAlias from types import GenericAlias
from typing import Any, Generic, Literal, NamedTuple, TypedDict, TypeVar, final, overload from typing import Any, Final, Generic, Literal, NamedTuple, TypedDict, TypeVar, final, overload
from typing_extensions import ParamSpec, Self, TypeAlias from typing_extensions import ParamSpec, Self, TypeAlias
__all__ = [ __all__ = [
@ -31,10 +31,16 @@ _RWrapped = TypeVar("_RWrapped")
_PWrapper = ParamSpec("_PWrapper") _PWrapper = ParamSpec("_PWrapper")
_RWrapper = TypeVar("_RWrapper") _RWrapper = TypeVar("_RWrapper")
if sys.version_info >= (3, 14):
@overload
def reduce(function: Callable[[_T, _S], _T], iterable: Iterable[_S], /, initial: _T) -> _T: ...
else:
@overload
def reduce(function: Callable[[_T, _S], _T], iterable: Iterable[_S], initial: _T, /) -> _T: ...
@overload @overload
def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T, /) -> _T: ... def reduce(function: Callable[[_T, _T], _T], iterable: Iterable[_T], /) -> _T: ...
@overload
def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T], /) -> _T: ...
class _CacheInfo(NamedTuple): class _CacheInfo(NamedTuple):
hits: int hits: int
@ -61,8 +67,20 @@ def lru_cache(maxsize: int | None = 128, typed: bool = False) -> Callable[[Calla
@overload @overload
def lru_cache(maxsize: Callable[..., _T], typed: bool = False) -> _lru_cache_wrapper[_T]: ... def lru_cache(maxsize: Callable[..., _T], typed: bool = False) -> _lru_cache_wrapper[_T]: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 14):
WRAPPER_ASSIGNMENTS: tuple[ WRAPPER_ASSIGNMENTS: Final[
tuple[
Literal["__module__"],
Literal["__name__"],
Literal["__qualname__"],
Literal["__doc__"],
Literal["__annotate__"],
Literal["__type_params__"],
]
]
elif sys.version_info >= (3, 12):
WRAPPER_ASSIGNMENTS: Final[
tuple[
Literal["__module__"], Literal["__module__"],
Literal["__name__"], Literal["__name__"],
Literal["__qualname__"], Literal["__qualname__"],
@ -70,10 +88,12 @@ if sys.version_info >= (3, 12):
Literal["__annotations__"], Literal["__annotations__"],
Literal["__type_params__"], Literal["__type_params__"],
] ]
else:
WRAPPER_ASSIGNMENTS: tuple[
Literal["__module__"], Literal["__name__"], Literal["__qualname__"], Literal["__doc__"], Literal["__annotations__"]
] ]
else:
WRAPPER_ASSIGNMENTS: Final[
tuple[Literal["__module__"], Literal["__name__"], Literal["__qualname__"], Literal["__doc__"], Literal["__annotations__"]]
]
WRAPPER_UPDATES: tuple[Literal["__dict__"]] WRAPPER_UPDATES: tuple[Literal["__dict__"]]
class _Wrapped(Generic[_PWrapped, _RWrapped, _PWrapper, _RWrapper]): class _Wrapped(Generic[_PWrapped, _RWrapped, _PWrapper, _RWrapper]):
@ -86,7 +106,20 @@ class _Wrapped(Generic[_PWrapped, _RWrapped, _PWrapper, _RWrapper]):
class _Wrapper(Generic[_PWrapped, _RWrapped]): class _Wrapper(Generic[_PWrapped, _RWrapped]):
def __call__(self, f: Callable[_PWrapper, _RWrapper]) -> _Wrapped[_PWrapped, _RWrapped, _PWrapper, _RWrapper]: ... def __call__(self, f: Callable[_PWrapper, _RWrapper]) -> _Wrapped[_PWrapped, _RWrapped, _PWrapper, _RWrapper]: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 14):
def update_wrapper(
wrapper: Callable[_PWrapper, _RWrapper],
wrapped: Callable[_PWrapped, _RWrapped],
assigned: Iterable[str] = ("__module__", "__name__", "__qualname__", "__doc__", "__annotate__", "__type_params__"),
updated: Iterable[str] = ("__dict__",),
) -> _Wrapped[_PWrapped, _RWrapped, _PWrapper, _RWrapper]: ...
def wraps(
wrapped: Callable[_PWrapped, _RWrapped],
assigned: Iterable[str] = ("__module__", "__name__", "__qualname__", "__doc__", "__annotate__", "__type_params__"),
updated: Iterable[str] = ("__dict__",),
) -> _Wrapper[_PWrapped, _RWrapped]: ...
elif sys.version_info >= (3, 12):
def update_wrapper( def update_wrapper(
wrapper: Callable[_PWrapper, _RWrapper], wrapper: Callable[_PWrapper, _RWrapper],
wrapped: Callable[_PWrapped, _RWrapped], wrapped: Callable[_PWrapped, _RWrapped],
@ -204,3 +237,11 @@ def _make_key(
type: Any = ..., type: Any = ...,
len: Callable[[Sized], int] = ..., len: Callable[[Sized], int] = ...,
) -> Hashable: ... ) -> Hashable: ...
if sys.version_info >= (3, 14):
@final
class _PlaceholderType: ...
Placeholder: Final[_PlaceholderType]
__all__ += ["Placeholder"]

View file

@ -1,8 +1,14 @@
import sys
from typing import TextIO from typing import TextIO
__all__ = ["getpass", "getuser", "GetPassWarning"] __all__ = ["getpass", "getuser", "GetPassWarning"]
def getpass(prompt: str = "Password: ", stream: TextIO | None = None) -> str: ... if sys.version_info >= (3, 14):
def getpass(prompt: str = "Password: ", stream: TextIO | None = None, *, echo_char: str | None = None) -> str: ...
else:
def getpass(prompt: str = "Password: ", stream: TextIO | None = None) -> str: ...
def getuser() -> str: ... def getuser() -> str: ...
class GetPassWarning(UserWarning): ... class GetPassWarning(UserWarning): ...

View file

@ -1,4 +1,3 @@
import _compression
import sys import sys
import zlib import zlib
from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath
@ -6,6 +5,11 @@ from io import FileIO, TextIOWrapper
from typing import Final, Literal, Protocol, overload from typing import Final, Literal, Protocol, overload
from typing_extensions import TypeAlias from typing_extensions import TypeAlias
if sys.version_info >= (3, 14):
from compression._common._streams import BaseStream, DecompressReader
else:
from _compression import BaseStream, DecompressReader
__all__ = ["BadGzipFile", "GzipFile", "open", "compress", "decompress"] __all__ = ["BadGzipFile", "GzipFile", "open", "compress", "decompress"]
_ReadBinaryMode: TypeAlias = Literal["r", "rb"] _ReadBinaryMode: TypeAlias = Literal["r", "rb"]
@ -84,7 +88,7 @@ class _PaddedFile:
class BadGzipFile(OSError): ... class BadGzipFile(OSError): ...
class GzipFile(_compression.BaseStream): class GzipFile(BaseStream):
myfileobj: FileIO | None myfileobj: FileIO | None
mode: object mode: object
name: str name: str
@ -153,7 +157,7 @@ class GzipFile(_compression.BaseStream):
def seek(self, offset: int, whence: int = 0) -> int: ... def seek(self, offset: int, whence: int = 0) -> int: ...
def readline(self, size: int | None = -1) -> bytes: ... def readline(self, size: int | None = -1) -> bytes: ...
class _GzipReader(_compression.DecompressReader): class _GzipReader(DecompressReader):
def __init__(self, fp: _ReadableFileobj) -> None: ... def __init__(self, fp: _ReadableFileobj) -> None: ...
def compress(data: SizedBuffer, compresslevel: int = 9, *, mtime: float | None = None) -> bytes: ... def compress(data: SizedBuffer, compresslevel: int = 9, *, mtime: float | None = None) -> bytes: ...

View file

@ -5,6 +5,7 @@ import sys
import types import types
from _typeshed import MaybeNone, ReadableBuffer, SupportsRead, SupportsReadline, WriteableBuffer from _typeshed import MaybeNone, ReadableBuffer, SupportsRead, SupportsReadline, WriteableBuffer
from collections.abc import Callable, Iterable, Iterator, Mapping from collections.abc import Callable, Iterable, Iterator, Mapping
from email._policybase import _MessageT
from socket import socket from socket import socket
from typing import BinaryIO, Literal, TypeVar, overload from typing import BinaryIO, Literal, TypeVar, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
@ -33,7 +34,6 @@ __all__ = [
_DataType: TypeAlias = SupportsRead[bytes] | Iterable[ReadableBuffer] | ReadableBuffer _DataType: TypeAlias = SupportsRead[bytes] | Iterable[ReadableBuffer] | ReadableBuffer
_T = TypeVar("_T") _T = TypeVar("_T")
_MessageT = TypeVar("_MessageT", bound=email.message.Message)
_HeaderValue: TypeAlias = ReadableBuffer | str | int _HeaderValue: TypeAlias = ReadableBuffer | str | int
HTTP_PORT: int HTTP_PORT: int

View file

@ -3,12 +3,25 @@ import email.message
import io import io
import socketserver import socketserver
import sys import sys
from _typeshed import StrPath, SupportsRead, SupportsWrite from _ssl import _PasswordType
from collections.abc import Mapping, Sequence from _typeshed import ReadableBuffer, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
from typing import Any, AnyStr, BinaryIO, ClassVar from collections.abc import Callable, Iterable, Mapping, Sequence
from typing_extensions import deprecated from ssl import Purpose, SSLContext
from typing import Any, AnyStr, BinaryIO, ClassVar, Protocol, type_check_only
from typing_extensions import Self, deprecated
__all__ = ["HTTPServer", "ThreadingHTTPServer", "BaseHTTPRequestHandler", "SimpleHTTPRequestHandler", "CGIHTTPRequestHandler"] if sys.version_info >= (3, 14):
__all__ = [
"HTTPServer",
"ThreadingHTTPServer",
"HTTPSServer",
"ThreadingHTTPSServer",
"BaseHTTPRequestHandler",
"SimpleHTTPRequestHandler",
"CGIHTTPRequestHandler",
]
else:
__all__ = ["HTTPServer", "ThreadingHTTPServer", "BaseHTTPRequestHandler", "SimpleHTTPRequestHandler", "CGIHTTPRequestHandler"]
class HTTPServer(socketserver.TCPServer): class HTTPServer(socketserver.TCPServer):
server_name: str server_name: str
@ -16,6 +29,39 @@ class HTTPServer(socketserver.TCPServer):
class ThreadingHTTPServer(socketserver.ThreadingMixIn, HTTPServer): ... class ThreadingHTTPServer(socketserver.ThreadingMixIn, HTTPServer): ...
if sys.version_info >= (3, 14):
@type_check_only
class _SSLModule(Protocol):
@staticmethod
def create_default_context(
purpose: Purpose = ...,
*,
cafile: StrOrBytesPath | None = None,
capath: StrOrBytesPath | None = None,
cadata: str | ReadableBuffer | None = None,
) -> SSLContext: ...
class HTTPSServer(HTTPServer):
ssl: _SSLModule
certfile: StrOrBytesPath
keyfile: StrOrBytesPath | None
password: _PasswordType | None
alpn_protocols: Iterable[str]
def __init__(
self,
server_address: socketserver._AfInetAddress,
RequestHandlerClass: Callable[[Any, _socket._RetAddress, Self], socketserver.BaseRequestHandler],
bind_and_activate: bool = True,
*,
certfile: StrOrBytesPath,
keyfile: StrOrBytesPath | None = None,
password: _PasswordType | None = None,
alpn_protocols: Iterable[str] | None = None,
) -> None: ...
def server_activate(self) -> None: ...
class ThreadingHTTPSServer(socketserver.ThreadingMixIn, HTTPSServer): ...
class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
client_address: tuple[str, int] client_address: tuple[str, int]
close_connection: bool close_connection: bool

View file

@ -1,16 +1,16 @@
import subprocess import subprocess
import sys import sys
import time import time
from _typeshed import ReadableBuffer, SizedBuffer from _typeshed import ReadableBuffer, SizedBuffer, Unused
from builtins import list as _list # conflicts with a method named "list" from builtins import list as _list # conflicts with a method named "list"
from collections.abc import Callable from collections.abc import Callable, Generator
from datetime import datetime from datetime import datetime
from re import Pattern from re import Pattern
from socket import socket as _socket from socket import socket as _socket
from ssl import SSLContext, SSLSocket from ssl import SSLContext, SSLSocket
from types import TracebackType from types import TracebackType
from typing import IO, Any, Literal, SupportsAbs, SupportsInt from typing import IO, Any, Literal, SupportsAbs, SupportsInt
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias, deprecated
__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"] __all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"]
@ -42,11 +42,17 @@ class IMAP4:
PROTOCOL_VERSION: str PROTOCOL_VERSION: str
def __init__(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ... def __init__(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ...
def open(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ... def open(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ...
if sys.version_info >= (3, 14):
@property
@deprecated("IMAP4.file is unsupported, can cause errors, and may be removed.")
def file(self) -> IO[str] | IO[bytes]: ...
else:
file: IO[str] | IO[bytes]
def __getattr__(self, attr: str) -> Any: ... def __getattr__(self, attr: str) -> Any: ...
host: str host: str
port: int port: int
sock: _socket sock: _socket
file: IO[str] | IO[bytes]
def read(self, size: int) -> bytes: ... def read(self, size: int) -> bytes: ...
def readline(self) -> bytes: ... def readline(self) -> bytes: ...
def send(self, data: ReadableBuffer) -> None: ... def send(self, data: ReadableBuffer) -> None: ...
@ -72,6 +78,9 @@ class IMAP4:
def getannotation(self, mailbox: str, entry: str, attribute: str) -> _CommandResults: ... def getannotation(self, mailbox: str, entry: str, attribute: str) -> _CommandResults: ...
def getquota(self, root: str) -> _CommandResults: ... def getquota(self, root: str) -> _CommandResults: ...
def getquotaroot(self, mailbox: str) -> _CommandResults: ... def getquotaroot(self, mailbox: str) -> _CommandResults: ...
if sys.version_info >= (3, 14):
def idle(self, duration: float | None = None) -> Idler: ...
def list(self, directory: str = '""', pattern: str = "*") -> tuple[str, _AnyResponseData]: ... def list(self, directory: str = '""', pattern: str = "*") -> tuple[str, _AnyResponseData]: ...
def login(self, user: str, password: str) -> tuple[Literal["OK"], _list[bytes]]: ... def login(self, user: str, password: str) -> tuple[Literal["OK"], _list[bytes]]: ...
def login_cram_md5(self, user: str, password: str) -> _CommandResults: ... def login_cram_md5(self, user: str, password: str) -> _CommandResults: ...
@ -100,6 +109,15 @@ class IMAP4:
def xatom(self, name: str, *args: str) -> _CommandResults: ... def xatom(self, name: str, *args: str) -> _CommandResults: ...
def print_log(self) -> None: ... def print_log(self) -> None: ...
if sys.version_info >= (3, 14):
class Idler:
def __init__(self, imap: IMAP4, duration: float | None = None) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, exc_type: object, exc_val: Unused, exc_tb: Unused) -> Literal[False]: ...
def __iter__(self) -> Self: ...
def __next__(self) -> tuple[str, float | None]: ...
def burst(self, interval: float = 0.1) -> Generator[tuple[str, float | None]]: ...
class IMAP4_SSL(IMAP4): class IMAP4_SSL(IMAP4):
if sys.version_info < (3, 12): if sys.version_info < (3, 12):
keyfile: str keyfile: str
@ -119,13 +137,24 @@ class IMAP4_SSL(IMAP4):
timeout: float | None = None, timeout: float | None = None,
) -> None: ... ) -> None: ...
sslobj: SSLSocket sslobj: SSLSocket
if sys.version_info >= (3, 14):
@property
@deprecated("IMAP4_SSL.file is unsupported, can cause errors, and may be removed.")
def file(self) -> IO[Any]: ...
else:
file: IO[Any] file: IO[Any]
def open(self, host: str = "", port: int | None = 993, timeout: float | None = None) -> None: ... def open(self, host: str = "", port: int | None = 993, timeout: float | None = None) -> None: ...
def ssl(self) -> SSLSocket: ... def ssl(self) -> SSLSocket: ...
class IMAP4_stream(IMAP4): class IMAP4_stream(IMAP4):
command: str command: str
def __init__(self, command: str) -> None: ... def __init__(self, command: str) -> None: ...
if sys.version_info >= (3, 14):
@property
@deprecated("IMAP4_stream.file is unsupported, can cause errors, and may be removed.")
def file(self) -> IO[Any]: ...
else:
file: IO[Any] file: IO[Any]
process: subprocess.Popen[bytes] process: subprocess.Popen[bytes]
writefile: IO[Any] writefile: IO[Any]

View file

@ -2,7 +2,7 @@ import dis
import enum import enum
import sys import sys
import types import types
from _typeshed import StrPath from _typeshed import AnnotationForm, StrPath
from collections import OrderedDict from collections import OrderedDict
from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine, Generator, Mapping, Sequence, Set as AbstractSet from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine, Generator, Mapping, Sequence, Set as AbstractSet
from types import ( from types import (
@ -28,6 +28,9 @@ from types import (
from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, TypeVar, overload from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, TypeVar, overload
from typing_extensions import ParamSpec, Self, TypeAlias, TypeGuard, TypeIs from typing_extensions import ParamSpec, Self, TypeAlias, TypeGuard, TypeIs
if sys.version_info >= (3, 14):
from annotationlib import Format
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
__all__ = [ __all__ = [
"ArgInfo", "ArgInfo",
@ -139,6 +142,8 @@ if sys.version_info >= (3, 11):
"getasyncgenstate", "getasyncgenstate",
"BufferFlags", "BufferFlags",
] ]
if sys.version_info >= (3, 14):
__all__ += ["CO_HAS_DOCSTRING", "CO_METHOD", "ispackage"]
_P = ParamSpec("_P") _P = ParamSpec("_P")
_T = TypeVar("_T") _T = TypeVar("_T")
@ -172,6 +177,9 @@ CO_COROUTINE: Final = 128
CO_ITERABLE_COROUTINE: Final = 256 CO_ITERABLE_COROUTINE: Final = 256
CO_ASYNC_GENERATOR: Final = 512 CO_ASYNC_GENERATOR: Final = 512
TPFLAGS_IS_ABSTRACT: Final = 1048576 TPFLAGS_IS_ABSTRACT: Final = 1048576
if sys.version_info >= (3, 14):
CO_HAS_DOCSTRING: Final = 67108864
CO_METHOD: Final = 134217728
modulesbyfile: dict[str, Any] modulesbyfile: dict[str, Any]
@ -199,6 +207,11 @@ def getmodulename(path: StrPath) -> str | None: ...
def ismodule(object: object) -> TypeIs[ModuleType]: ... def ismodule(object: object) -> TypeIs[ModuleType]: ...
def isclass(object: object) -> TypeIs[type[Any]]: ... def isclass(object: object) -> TypeIs[type[Any]]: ...
def ismethod(object: object) -> TypeIs[MethodType]: ... def ismethod(object: object) -> TypeIs[MethodType]: ...
if sys.version_info >= (3, 14):
# Not TypeIs because it does not return True for all modules
def ispackage(object: object) -> TypeGuard[ModuleType]: ...
def isfunction(object: object) -> TypeIs[FunctionType]: ... def isfunction(object: object) -> TypeIs[FunctionType]: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
@ -294,7 +307,18 @@ _IntrospectableCallable: TypeAlias = Callable[..., Any]
# #
# Introspecting callables with the Signature object # Introspecting callables with the Signature object
# #
if sys.version_info >= (3, 10): if sys.version_info >= (3, 14):
def signature(
obj: _IntrospectableCallable,
*,
follow_wrapped: bool = True,
globals: Mapping[str, Any] | None = None,
locals: Mapping[str, Any] | None = None,
eval_str: bool = False,
annotation_format: Format = Format.VALUE, # noqa: Y011
) -> Signature: ...
elif sys.version_info >= (3, 10):
def signature( def signature(
obj: _IntrospectableCallable, obj: _IntrospectableCallable,
*, *,
@ -323,7 +347,19 @@ class Signature:
def bind_partial(self, *args: Any, **kwargs: Any) -> BoundArguments: ... def bind_partial(self, *args: Any, **kwargs: Any) -> BoundArguments: ...
def replace(self, *, parameters: Sequence[Parameter] | type[_void] | None = ..., return_annotation: Any = ...) -> Self: ... def replace(self, *, parameters: Sequence[Parameter] | type[_void] | None = ..., return_annotation: Any = ...) -> Self: ...
__replace__ = replace __replace__ = replace
if sys.version_info >= (3, 10): if sys.version_info >= (3, 14):
@classmethod
def from_callable(
cls,
obj: _IntrospectableCallable,
*,
follow_wrapped: bool = True,
globals: Mapping[str, Any] | None = None,
locals: Mapping[str, Any] | None = None,
eval_str: bool = False,
annotation_format: Format = Format.VALUE, # noqa: Y011
) -> Self: ...
elif sys.version_info >= (3, 10):
@classmethod @classmethod
def from_callable( def from_callable(
cls, cls,
@ -337,20 +373,24 @@ class Signature:
else: else:
@classmethod @classmethod
def from_callable(cls, obj: _IntrospectableCallable, *, follow_wrapped: bool = True) -> Self: ... def from_callable(cls, obj: _IntrospectableCallable, *, follow_wrapped: bool = True) -> Self: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 14):
def format(self, *, max_width: int | None = None, quote_annotation_strings: bool = True) -> str: ...
elif sys.version_info >= (3, 13):
def format(self, *, max_width: int | None = None) -> str: ... def format(self, *, max_width: int | None = None) -> str: ...
def __eq__(self, other: object) -> bool: ... def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ... def __hash__(self) -> int: ...
if sys.version_info >= (3, 10): if sys.version_info >= (3, 14):
from annotationlib import get_annotations as get_annotations
elif sys.version_info >= (3, 10):
def get_annotations( def get_annotations(
obj: Callable[..., object] | type[object] | ModuleType, # any callable, class, or module obj: Callable[..., object] | type[object] | ModuleType, # any callable, class, or module
*, *,
globals: Mapping[str, Any] | None = None, # value types depend on the key globals: Mapping[str, Any] | None = None, # value types depend on the key
locals: Mapping[str, Any] | None = None, # value types depend on the key locals: Mapping[str, Any] | None = None, # value types depend on the key
eval_str: bool = False, eval_str: bool = False,
) -> dict[str, Any]: ... # values are type expressions ) -> dict[str, AnnotationForm]: ... # values are type expressions
# The name is the same as the enum's name in CPython # The name is the same as the enum's name in CPython
class _ParameterKind(enum.IntEnum): class _ParameterKind(enum.IntEnum):
@ -461,7 +501,13 @@ class ArgInfo(NamedTuple):
locals: dict[str, Any] locals: dict[str, Any]
def getargvalues(frame: FrameType) -> ArgInfo: ... def getargvalues(frame: FrameType) -> ArgInfo: ...
def formatannotation(annotation: object, base_module: str | None = None) -> str: ...
if sys.version_info >= (3, 14):
def formatannotation(annotation: object, base_module: str | None = None, *, quote_annotation_strings: bool = True) -> str: ...
else:
def formatannotation(annotation: object, base_module: str | None = None) -> str: ...
def formatannotationrelativeto(object: object) -> Callable[[object], str]: ... def formatannotationrelativeto(object: object) -> Callable[[object], str]: ...
if sys.version_info < (3, 11): if sys.version_info < (3, 11):

View file

@ -20,7 +20,7 @@ from _io import (
open as open, open as open,
open_code as open_code, open_code as open_code,
) )
from typing import Final from typing import Final, Protocol, TypeVar
__all__ = [ __all__ = [
"BlockingIOError", "BlockingIOError",
@ -44,11 +44,17 @@ __all__ = [
"SEEK_END", "SEEK_END",
] ]
if sys.version_info >= (3, 14):
__all__ += ["Reader", "Writer"]
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
from _io import text_encoding as text_encoding from _io import text_encoding as text_encoding
__all__ += ["DEFAULT_BUFFER_SIZE", "IncrementalNewlineDecoder", "text_encoding"] __all__ += ["DEFAULT_BUFFER_SIZE", "IncrementalNewlineDecoder", "text_encoding"]
_T_co = TypeVar("_T_co", covariant=True)
_T_contra = TypeVar("_T_contra", contravariant=True)
SEEK_SET: Final = 0 SEEK_SET: Final = 0
SEEK_CUR: Final = 1 SEEK_CUR: Final = 1
SEEK_END: Final = 2 SEEK_END: Final = 2
@ -58,3 +64,10 @@ class IOBase(_IOBase, metaclass=abc.ABCMeta): ...
class RawIOBase(_RawIOBase, IOBase): ... class RawIOBase(_RawIOBase, IOBase): ...
class BufferedIOBase(_BufferedIOBase, IOBase): ... class BufferedIOBase(_BufferedIOBase, IOBase): ...
class TextIOBase(_TextIOBase, IOBase): ... class TextIOBase(_TextIOBase, IOBase): ...
if sys.version_info >= (3, 14):
class Reader(Protocol[_T_co]):
def read(self, size: int = ..., /) -> _T_co: ...
class Writer(Protocol[_T_contra]):
def write(self, data: _T_contra, /) -> int: ...

View file

@ -28,6 +28,7 @@ class _IPAddressBase:
def exploded(self) -> str: ... def exploded(self) -> str: ...
@property @property
def reverse_pointer(self) -> str: ... def reverse_pointer(self) -> str: ...
if sys.version_info < (3, 14):
@property @property
def version(self) -> int: ... def version(self) -> int: ...
@ -104,6 +105,10 @@ class _BaseNetwork(_IPAddressBase, Generic[_A]):
def hostmask(self) -> _A: ... def hostmask(self) -> _A: ...
class _BaseV4: class _BaseV4:
if sys.version_info >= (3, 14):
version: Final = 4
max_prefixlen: Final = 32
else:
@property @property
def version(self) -> Literal[4]: ... def version(self) -> Literal[4]: ...
@property @property
@ -151,6 +156,10 @@ class IPv4Interface(IPv4Address):
def with_prefixlen(self) -> str: ... def with_prefixlen(self) -> str: ...
class _BaseV6: class _BaseV6:
if sys.version_info >= (3, 14):
version: Final = 6
max_prefixlen: Final = 128
else:
@property @property
def version(self) -> Literal[6]: ... def version(self) -> Literal[6]: ...
@property @property

View file

@ -8,7 +8,9 @@ from logging import FileHandler, Handler, LogRecord
from re import Pattern from re import Pattern
from socket import SocketKind, socket from socket import SocketKind, socket
from threading import Thread from threading import Thread
from types import TracebackType
from typing import Any, ClassVar, Final, Protocol, TypeVar from typing import Any, ClassVar, Final, Protocol, TypeVar
from typing_extensions import Self
_T = TypeVar("_T") _T = TypeVar("_T")
@ -142,6 +144,16 @@ class SysLogHandler(Handler):
priority_names: ClassVar[dict[str, int]] # undocumented priority_names: ClassVar[dict[str, int]] # undocumented
facility_names: ClassVar[dict[str, int]] # undocumented facility_names: ClassVar[dict[str, int]] # undocumented
priority_map: ClassVar[dict[str, str]] # undocumented priority_map: ClassVar[dict[str, str]] # undocumented
if sys.version_info >= (3, 14):
timeout: float | None
def __init__(
self,
address: tuple[str, int] | str = ("localhost", 514),
facility: str | int = 1,
socktype: SocketKind | None = None,
timeout: float | None = None,
) -> None: ...
else:
def __init__( def __init__(
self, address: tuple[str, int] | str = ("localhost", 514), facility: str | int = 1, socktype: SocketKind | None = None self, address: tuple[str, int] | str = ("localhost", 514), facility: str | int = 1, socktype: SocketKind | None = None
) -> None: ... ) -> None: ...
@ -237,3 +249,9 @@ class QueueListener:
def stop(self) -> None: ... def stop(self) -> None: ...
def enqueue_sentinel(self) -> None: ... def enqueue_sentinel(self) -> None: ...
def handle(self, record: LogRecord) -> None: ... def handle(self, record: LogRecord) -> None: ...
if sys.version_info >= (3, 14):
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> None: ...

View file

@ -1,4 +1,4 @@
from _compression import BaseStream import sys
from _lzma import ( from _lzma import (
CHECK_CRC32 as CHECK_CRC32, CHECK_CRC32 as CHECK_CRC32,
CHECK_CRC64 as CHECK_CRC64, CHECK_CRC64 as CHECK_CRC64,
@ -38,6 +38,11 @@ from _typeshed import ReadableBuffer, StrOrBytesPath
from typing import IO, Literal, TextIO, overload from typing import IO, Literal, TextIO, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 14):
from compression._common._streams import BaseStream
else:
from _compression import BaseStream
__all__ = [ __all__ = [
"CHECK_NONE", "CHECK_NONE",
"CHECK_CRC32", "CHECK_CRC32",

View file

@ -4,6 +4,7 @@ import sys
from _typeshed import StrPath, SupportsNoArgReadline, SupportsRead from _typeshed import StrPath, SupportsNoArgReadline, SupportsRead
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from email._policybase import _MessageT
from types import GenericAlias, TracebackType from types import GenericAlias, TracebackType
from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeVar, overload from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeVar, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
@ -29,7 +30,6 @@ __all__ = [
] ]
_T = TypeVar("_T") _T = TypeVar("_T")
_MessageT = TypeVar("_MessageT", bound=Message)
class _SupportsReadAndReadline(SupportsRead[bytes], SupportsNoArgReadline[bytes], Protocol): ... class _SupportsReadAndReadline(SupportsRead[bytes], SupportsNoArgReadline[bytes], Protocol): ...

View file

@ -2,10 +2,10 @@ import builtins
import sys import sys
import types import types
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
from typing import Any from typing import Any, Final
from typing_extensions import TypeAlias from typing_extensions import TypeAlias
version: int version: Final[int]
_Marshallable: TypeAlias = ( _Marshallable: TypeAlias = (
# handled in w_object() in marshal.c # handled in w_object() in marshal.c
@ -28,14 +28,22 @@ _Marshallable: TypeAlias = (
| ReadableBuffer | ReadableBuffer
) )
if sys.version_info >= (3, 13): if sys.version_info >= (3, 14):
def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 5, /, *, allow_code: bool = True) -> None: ...
def dumps(value: _Marshallable, version: int = 5, /, *, allow_code: bool = True) -> bytes: ...
elif sys.version_info >= (3, 13):
def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 4, /, *, allow_code: bool = True) -> None: ... def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 4, /, *, allow_code: bool = True) -> None: ...
def load(file: SupportsRead[bytes], /, *, allow_code: bool = True) -> Any: ...
def dumps(value: _Marshallable, version: int = 4, /, *, allow_code: bool = True) -> bytes: ... def dumps(value: _Marshallable, version: int = 4, /, *, allow_code: bool = True) -> bytes: ...
def loads(bytes: ReadableBuffer, /, *, allow_code: bool = True) -> Any: ...
else: else:
def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 4, /) -> None: ... def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 4, /) -> None: ...
def load(file: SupportsRead[bytes], /) -> Any: ...
def dumps(value: _Marshallable, version: int = 4, /) -> bytes: ... def dumps(value: _Marshallable, version: int = 4, /) -> bytes: ...
if sys.version_info >= (3, 13):
def load(file: SupportsRead[bytes], /, *, allow_code: bool = True) -> Any: ...
def loads(bytes: ReadableBuffer, /, *, allow_code: bool = True) -> Any: ...
else:
def load(file: SupportsRead[bytes], /) -> Any: ...
def loads(bytes: ReadableBuffer, /) -> Any: ... def loads(bytes: ReadableBuffer, /) -> Any: ...

View file

@ -1,2 +1,12 @@
def url2pathname(url: str) -> str: ... import sys
def pathname2url(p: str) -> str: ... from typing_extensions import deprecated
if sys.version_info >= (3, 14):
@deprecated("nturl2path module was deprecated since Python 3.14")
def url2pathname(url: str) -> str: ...
@deprecated("nturl2path module was deprecated since Python 3.14")
def pathname2url(p: str) -> str: ...
else:
def url2pathname(url: str) -> str: ...
def pathname2url(p: str) -> str: ...

View file

@ -160,6 +160,8 @@ __all__ = [
"walk", "walk",
"write", "write",
] ]
if sys.version_info >= (3, 14):
__all__ += ["readinto"]
if sys.platform == "darwin" and sys.version_info >= (3, 12): if sys.platform == "darwin" and sys.version_info >= (3, 12):
__all__ += ["PRIO_DARWIN_BG", "PRIO_DARWIN_NONUI", "PRIO_DARWIN_PROCESS", "PRIO_DARWIN_THREAD"] __all__ += ["PRIO_DARWIN_BG", "PRIO_DARWIN_NONUI", "PRIO_DARWIN_PROCESS", "PRIO_DARWIN_THREAD"]
if sys.platform == "darwin" and sys.version_info >= (3, 10): if sys.platform == "darwin" and sys.version_info >= (3, 10):
@ -208,6 +210,8 @@ if sys.platform == "linux":
"removexattr", "removexattr",
"setxattr", "setxattr",
] ]
if sys.platform == "linux" and sys.version_info >= (3, 14):
__all__ += ["SCHED_DEADLINE", "SCHED_NORMAL"]
if sys.platform == "linux" and sys.version_info >= (3, 13): if sys.platform == "linux" and sys.version_info >= (3, 13):
__all__ += [ __all__ += [
"POSIX_SPAWN_CLOSEFROM", "POSIX_SPAWN_CLOSEFROM",
@ -570,6 +574,10 @@ if sys.platform == "linux":
SCHED_IDLE: int SCHED_IDLE: int
SCHED_RESET_ON_FORK: int SCHED_RESET_ON_FORK: int
if sys.version_info >= (3, 14) and sys.platform == "linux":
SCHED_DEADLINE: int
SCHED_NORMAL: int
if sys.platform != "win32": if sys.platform != "win32":
RTLD_LAZY: int RTLD_LAZY: int
RTLD_NOW: int RTLD_NOW: int
@ -1149,6 +1157,9 @@ if sys.platform != "win32":
def readv(fd: int, buffers: SupportsLenAndGetItem[WriteableBuffer], /) -> int: ... def readv(fd: int, buffers: SupportsLenAndGetItem[WriteableBuffer], /) -> int: ...
def writev(fd: int, buffers: SupportsLenAndGetItem[ReadableBuffer], /) -> int: ... def writev(fd: int, buffers: SupportsLenAndGetItem[ReadableBuffer], /) -> int: ...
if sys.version_info >= (3, 14):
def readinto(fd: int, buffer: ReadableBuffer, /) -> int: ...
@final @final
class terminal_size(structseq[int], tuple[int, int]): class terminal_size(structseq[int], tuple[int, int]):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):

View file

@ -15,11 +15,16 @@ from collections.abc import Callable, Generator, Iterator, Sequence
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from os import PathLike, stat_result from os import PathLike, stat_result
from types import GenericAlias, TracebackType from types import GenericAlias, TracebackType
from typing import IO, Any, BinaryIO, ClassVar, Literal, overload from typing import IO, Any, BinaryIO, ClassVar, Literal, TypeVar, overload
from typing_extensions import Never, Self, deprecated from typing_extensions import Never, Self, deprecated
_PathT = TypeVar("_PathT", bound=PurePath)
__all__ = ["PurePath", "PurePosixPath", "PureWindowsPath", "Path", "PosixPath", "WindowsPath"] __all__ = ["PurePath", "PurePosixPath", "PureWindowsPath", "Path", "PosixPath", "WindowsPath"]
if sys.version_info >= (3, 14):
from pathlib.types import PathInfo
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
__all__ += ["UnsupportedOperation"] __all__ += ["UnsupportedOperation"]
@ -63,7 +68,9 @@ class PurePath(PathLike[str]):
def as_uri(self) -> str: ... def as_uri(self) -> str: ...
def is_absolute(self) -> bool: ... def is_absolute(self) -> bool: ...
def is_reserved(self) -> bool: ... def is_reserved(self) -> bool: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 14):
def is_relative_to(self, other: StrPath) -> bool: ...
elif sys.version_info >= (3, 12):
def is_relative_to(self, other: StrPath, /, *_deprecated: StrPath) -> bool: ... def is_relative_to(self, other: StrPath, /, *_deprecated: StrPath) -> bool: ...
else: else:
def is_relative_to(self, *other: StrPath) -> bool: ... def is_relative_to(self, *other: StrPath) -> bool: ...
@ -73,7 +80,9 @@ class PurePath(PathLike[str]):
else: else:
def match(self, path_pattern: str) -> bool: ... def match(self, path_pattern: str) -> bool: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 14):
def relative_to(self, other: StrPath, *, walk_up: bool = False) -> Self: ...
elif sys.version_info >= (3, 12):
def relative_to(self, other: StrPath, /, *_deprecated: StrPath, walk_up: bool = False) -> Self: ... def relative_to(self, other: StrPath, /, *_deprecated: StrPath, walk_up: bool = False) -> Self: ...
else: else:
def relative_to(self, *other: StrPath) -> Self: ... def relative_to(self, *other: StrPath) -> Self: ...
@ -154,17 +163,25 @@ class Path(PurePath):
def mkdir(self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False) -> None: ... def mkdir(self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False) -> None: ...
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
def copy(self, target: StrPath, *, follow_symlinks: bool = True, preserve_metadata: bool = False) -> None: ...
def copytree( @property
self, def info(self) -> PathInfo: ...
target: StrPath, @overload
*, def move_into(self, target_dir: _PathT) -> _PathT: ... # type: ignore[overload-overlap]
follow_symlinks: bool = True, @overload
preserve_metadata: bool = False, def move_into(self, target_dir: StrPath) -> Self: ... # type: ignore[overload-overlap]
dirs_exist_ok: bool = False, @overload
ignore: Callable[[Self], bool] | None = None, def move(self, target: _PathT) -> _PathT: ... # type: ignore[overload-overlap]
on_error: Callable[[OSError], object] | None = None, @overload
) -> None: ... def move(self, target: StrPath) -> Self: ... # type: ignore[overload-overlap]
@overload
def copy_into(self, target_dir: _PathT, *, follow_symlinks: bool = True, preserve_metadata: bool = False) -> _PathT: ... # type: ignore[overload-overlap]
@overload
def copy_into(self, target_dir: StrPath, *, follow_symlinks: bool = True, preserve_metadata: bool = False) -> Self: ... # type: ignore[overload-overlap]
@overload
def copy(self, target: _PathT, *, follow_symlinks: bool = True, preserve_metadata: bool = False) -> _PathT: ... # type: ignore[overload-overlap]
@overload
def copy(self, target: StrPath, *, follow_symlinks: bool = True, preserve_metadata: bool = False) -> Self: ... # type: ignore[overload-overlap]
# Adapted from builtins.open # Adapted from builtins.open
# Text mode: always returns a TextIOWrapper # Text mode: always returns a TextIOWrapper
@ -253,9 +270,6 @@ class Path(PurePath):
def resolve(self, strict: bool = False) -> Self: ... def resolve(self, strict: bool = False) -> Self: ...
def rmdir(self) -> None: ... def rmdir(self) -> None: ...
if sys.version_info >= (3, 14):
def delete(self, ignore_errors: bool = False, on_error: Callable[[OSError], object] | None = None) -> None: ...
def symlink_to(self, target: StrOrBytesPath, target_is_directory: bool = False) -> None: ... def symlink_to(self, target: StrOrBytesPath, target_is_directory: bool = False) -> None: ...
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
def hardlink_to(self, target: StrOrBytesPath) -> None: ... def hardlink_to(self, target: StrOrBytesPath) -> None: ...
@ -286,9 +300,6 @@ class Path(PurePath):
self, top_down: bool = ..., on_error: Callable[[OSError], object] | None = ..., follow_symlinks: bool = ... self, top_down: bool = ..., on_error: Callable[[OSError], object] | None = ..., follow_symlinks: bool = ...
) -> Iterator[tuple[Self, list[str], list[str]]]: ... ) -> Iterator[tuple[Self, list[str], list[str]]]: ...
if sys.version_info >= (3, 14):
def rmtree(self, ignore_errors: bool = False, on_error: Callable[[OSError], object] | None = None) -> None: ...
class PosixPath(Path, PurePosixPath): ... class PosixPath(Path, PurePosixPath): ...
class WindowsPath(Path, PureWindowsPath): ... class WindowsPath(Path, PureWindowsPath): ...

View file

@ -0,0 +1,8 @@
from typing import Protocol, runtime_checkable
@runtime_checkable
class PathInfo(Protocol):
def exists(self, *, follow_symlinks: bool = True) -> bool: ...
def is_dir(self, *, follow_symlinks: bool = True) -> bool: ...
def is_file(self, *, follow_symlinks: bool = True) -> bool: ...
def is_symlink(self) -> bool: ...

View file

@ -1,17 +1,21 @@
import signal import signal
import sys import sys
from bdb import Bdb from bdb import Bdb, _Backend
from cmd import Cmd from cmd import Cmd
from collections.abc import Callable, Iterable, Mapping, Sequence from collections.abc import Callable, Iterable, Mapping, Sequence
from inspect import _SourceObjectType from inspect import _SourceObjectType
from linecache import _ModuleGlobals
from types import CodeType, FrameType, TracebackType from types import CodeType, FrameType, TracebackType
from typing import IO, Any, ClassVar, Final, TypeVar from typing import IO, Any, ClassVar, Final, Literal, TypeVar
from typing_extensions import ParamSpec, Self from typing_extensions import ParamSpec, Self, TypeAlias
__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", "post_mortem", "help"] __all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", "post_mortem", "help"]
if sys.version_info >= (3, 14):
__all__ += ["set_default_backend", "get_default_backend"]
_T = TypeVar("_T") _T = TypeVar("_T")
_P = ParamSpec("_P") _P = ParamSpec("_P")
_Mode: TypeAlias = Literal["inline", "cli"]
line_prefix: str # undocumented line_prefix: str # undocumented
@ -21,7 +25,16 @@ def run(statement: str, globals: dict[str, Any] | None = None, locals: Mapping[s
def runeval(expression: str, globals: dict[str, Any] | None = None, locals: Mapping[str, Any] | None = None) -> Any: ... def runeval(expression: str, globals: dict[str, Any] | None = None, locals: Mapping[str, Any] | None = None) -> Any: ...
def runctx(statement: str, globals: dict[str, Any], locals: Mapping[str, Any]) -> None: ... def runctx(statement: str, globals: dict[str, Any], locals: Mapping[str, Any]) -> None: ...
def runcall(func: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> _T | None: ... def runcall(func: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> _T | None: ...
def set_trace(*, header: str | None = None) -> None: ...
if sys.version_info >= (3, 14):
def set_default_backend(backend: _Backend) -> None: ...
def get_default_backend() -> _Backend: ...
def set_trace(*, header: str | None = None, commands: Iterable[str] | None = None) -> None: ...
async def set_trace_async(*, header: str | None = None, commands: Iterable[str] | None = None) -> None: ...
else:
def set_trace(*, header: str | None = None) -> None: ...
def post_mortem(t: TracebackType | None = None) -> None: ... def post_mortem(t: TracebackType | None = None) -> None: ...
def pm() -> None: ... def pm() -> None: ...
@ -47,6 +60,22 @@ class Pdb(Bdb, Cmd):
curindex: int curindex: int
curframe: FrameType | None curframe: FrameType | None
curframe_locals: Mapping[str, Any] curframe_locals: Mapping[str, Any]
if sys.version_info >= (3, 14):
mode: _Mode | None
colorize: bool
def __init__(
self,
completekey: str = "tab",
stdin: IO[str] | None = None,
stdout: IO[str] | None = None,
skip: Iterable[str] | None = None,
nosigint: bool = False,
readrc: bool = True,
mode: _Mode | None = None,
backend: _Backend | None = None,
colorize: bool = False,
) -> None: ...
else:
def __init__( def __init__(
self, self,
completekey: str = "tab", completekey: str = "tab",
@ -56,6 +85,10 @@ class Pdb(Bdb, Cmd):
nosigint: bool = False, nosigint: bool = False,
readrc: bool = True, readrc: bool = True,
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 14):
def set_trace(self, frame: FrameType | None = None, *, commands: Iterable[str] | None = None) -> None: ...
async def set_trace_async(self, frame: FrameType | None = None, *, commands: Iterable[str] | None = None) -> None: ...
def forget(self) -> None: ... def forget(self) -> None: ...
def setup(self, f: FrameType | None, tb: TracebackType | None) -> None: ... def setup(self, f: FrameType | None, tb: TracebackType | None) -> None: ...
if sys.version_info < (3, 11): if sys.version_info < (3, 11):
@ -75,14 +108,25 @@ class Pdb(Bdb, Cmd):
def handle_command_def(self, line: str) -> bool: ... def handle_command_def(self, line: str) -> bool: ...
def defaultFile(self) -> str: ... def defaultFile(self) -> str: ...
def lineinfo(self, identifier: str) -> tuple[None, None, None] | tuple[str, str, int]: ... def lineinfo(self, identifier: str) -> tuple[None, None, None] | tuple[str, str, int]: ...
if sys.version_info >= (3, 14):
def checkline(self, filename: str, lineno: int, module_globals: _ModuleGlobals | None = None) -> int: ...
else:
def checkline(self, filename: str, lineno: int) -> int: ... def checkline(self, filename: str, lineno: int) -> int: ...
def _getval(self, arg: str) -> object: ... def _getval(self, arg: str) -> object: ...
if sys.version_info >= (3, 14):
def print_stack_trace(self, count: int | None = None) -> None: ...
else:
def print_stack_trace(self) -> None: ... def print_stack_trace(self) -> None: ...
def print_stack_entry(self, frame_lineno: tuple[FrameType, int], prompt_prefix: str = "\n-> ") -> None: ... def print_stack_entry(self, frame_lineno: tuple[FrameType, int], prompt_prefix: str = "\n-> ") -> None: ...
def lookupmodule(self, filename: str) -> str | None: ... def lookupmodule(self, filename: str) -> str | None: ...
if sys.version_info < (3, 11): if sys.version_info < (3, 11):
def _runscript(self, filename: str) -> None: ... def _runscript(self, filename: str) -> None: ...
if sys.version_info >= (3, 14):
def complete_multiline_names(self, text: str, line: str, begidx: int, endidx: int) -> list[str]: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def completedefault(self, text: str, line: str, begidx: int, endidx: int) -> list[str]: ... def completedefault(self, text: str, line: str, begidx: int, endidx: int) -> list[str]: ...

View file

@ -8,8 +8,6 @@ from typing_extensions import deprecated
__all__ = [ __all__ = [
"get_importer", "get_importer",
"iter_importers", "iter_importers",
"get_loader",
"find_loader",
"walk_packages", "walk_packages",
"iter_modules", "iter_modules",
"get_data", "get_data",
@ -17,6 +15,8 @@ __all__ = [
"extend_path", "extend_path",
"ModuleInfo", "ModuleInfo",
] ]
if sys.version_info < (3, 14):
__all__ += ["get_loader", "find_loader"]
if sys.version_info < (3, 12): if sys.version_info < (3, 12):
__all__ += ["ImpImporter", "ImpLoader"] __all__ += ["ImpImporter", "ImpLoader"]
@ -36,11 +36,13 @@ if sys.version_info < (3, 12):
class ImpLoader: class ImpLoader:
def __init__(self, fullname: str, file: IO[str], filename: StrOrBytesPath, etc: tuple[str, str, int]) -> None: ... def __init__(self, fullname: str, file: IO[str], filename: StrOrBytesPath, etc: tuple[str, str, int]) -> None: ...
@deprecated("Use importlib.util.find_spec() instead. Will be removed in Python 3.14.") if sys.version_info < (3, 14):
def find_loader(fullname: str) -> LoaderProtocol | None: ... @deprecated("Use importlib.util.find_spec() instead. Will be removed in Python 3.14.")
def find_loader(fullname: str) -> LoaderProtocol | None: ...
@deprecated("Use importlib.util.find_spec() instead. Will be removed in Python 3.14.")
def get_loader(module_or_name: str) -> LoaderProtocol | None: ...
def get_importer(path_item: StrOrBytesPath) -> PathEntryFinderProtocol | None: ... def get_importer(path_item: StrOrBytesPath) -> PathEntryFinderProtocol | None: ...
@deprecated("Use importlib.util.find_spec() instead. Will be removed in Python 3.14.")
def get_loader(module_or_name: str) -> LoaderProtocol | None: ...
def iter_importers(fullname: str = "") -> Iterator[MetaPathFinderProtocol | PathEntryFinderProtocol]: ... def iter_importers(fullname: str = "") -> Iterator[MetaPathFinderProtocol | PathEntryFinderProtocol]: ...
def iter_modules(path: Iterable[StrOrBytesPath] | None = None, prefix: str = "") -> Iterator[ModuleInfo]: ... def iter_modules(path: Iterable[StrOrBytesPath] | None = None, prefix: str = "") -> Iterator[ModuleInfo]: ...
def read_code(stream: SupportsRead[bytes]) -> Any: ... # undocumented def read_code(stream: SupportsRead[bytes]) -> Any: ... # undocumented

View file

@ -82,3 +82,6 @@ if sys.version_info >= (3, 13):
is_emulator: bool = False, is_emulator: bool = False,
) -> AndroidVer: ... ) -> AndroidVer: ...
def ios_ver(system: str = "", release: str = "", model: str = "", is_simulator: bool = False) -> IOSVersionInfo: ... def ios_ver(system: str = "", release: str = "", model: str = "", is_simulator: bool = False) -> IOSVersionInfo: ...
if sys.version_info >= (3, 14):
def invalidate_caches() -> None: ...

View file

@ -250,6 +250,12 @@ if sys.platform != "win32":
timerfd_settime_ns as timerfd_settime_ns, timerfd_settime_ns as timerfd_settime_ns,
) )
if sys.version_info >= (3, 14):
from os import readinto as readinto
if sys.version_info >= (3, 14) and sys.platform == "linux":
from os import SCHED_DEADLINE as SCHED_DEADLINE, SCHED_NORMAL as SCHED_NORMAL
if sys.platform != "linux": if sys.platform != "linux":
from os import O_EXLOCK as O_EXLOCK, O_SHLOCK as O_SHLOCK, chflags as chflags, lchflags as lchflags, lchmod as lchmod from os import O_EXLOCK as O_EXLOCK, O_SHLOCK as O_SHLOCK, chflags as chflags, lchflags as lchflags, lchmod as lchmod

View file

@ -1023,6 +1023,39 @@ if sys.platform != "linux":
__all__ += ["IPPROTO_GGP", "IPPROTO_IPV4", "IPPROTO_MAX", "IPPROTO_ND", "IP_RECVDSTADDR", "SO_USELOOPBACK"] __all__ += ["IPPROTO_GGP", "IPPROTO_IPV4", "IPPROTO_MAX", "IPPROTO_ND", "IP_RECVDSTADDR", "SO_USELOOPBACK"]
if sys.version_info >= (3, 14):
from _socket import IP_RECVTTL as IP_RECVTTL
__all__ += ["IP_RECVTTL"]
if sys.platform == "win32" or sys.platform == "linux":
from _socket import IP_RECVERR as IP_RECVERR, IPV6_RECVERR as IPV6_RECVERR, SO_ORIGINAL_DST as SO_ORIGINAL_DST
__all__ += ["IP_RECVERR", "IPV6_RECVERR", "SO_ORIGINAL_DST"]
if sys.platform == "win32":
from _socket import (
SO_BTH_ENCRYPT as SO_BTH_ENCRYPT,
SO_BTH_MTU as SO_BTH_MTU,
SO_BTH_MTU_MAX as SO_BTH_MTU_MAX,
SO_BTH_MTU_MIN as SO_BTH_MTU_MIN,
SOL_RFCOMM as SOL_RFCOMM,
TCP_QUICKACK as TCP_QUICKACK,
)
__all__ += ["SOL_RFCOMM", "SO_BTH_ENCRYPT", "SO_BTH_MTU", "SO_BTH_MTU_MAX", "SO_BTH_MTU_MIN", "TCP_QUICKACK"]
if sys.platform == "linux":
from _socket import (
CAN_RAW_ERR_FILTER as CAN_RAW_ERR_FILTER,
IP_FREEBIND as IP_FREEBIND,
IP_RECVORIGDSTADDR as IP_RECVORIGDSTADDR,
SO_ORIGINAL_DST as SO_ORIGINAL_DST,
VMADDR_CID_LOCAL as VMADDR_CID_LOCAL,
)
__all__ += ["CAN_RAW_ERR_FILTER", "IP_FREEBIND", "IP_RECVORIGDSTADDR", "VMADDR_CID_LOCAL"]
# Re-exported from errno # Re-exported from errno
EBADF: int EBADF: int
EAGAIN: int EAGAIN: int

View file

@ -60,12 +60,14 @@ from sqlite3.dbapi2 import (
sqlite_version as sqlite_version, sqlite_version as sqlite_version,
sqlite_version_info as sqlite_version_info, sqlite_version_info as sqlite_version_info,
threadsafety as threadsafety, threadsafety as threadsafety,
version_info as version_info,
) )
from types import TracebackType from types import TracebackType
from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, final, overload, type_check_only from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, final, overload, type_check_only
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info < (3, 14):
from sqlite3.dbapi2 import version_info as version_info
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
from sqlite3.dbapi2 import ( from sqlite3.dbapi2 import (
LEGACY_TRANSACTION_CONTROL as LEGACY_TRANSACTION_CONTROL, LEGACY_TRANSACTION_CONTROL as LEGACY_TRANSACTION_CONTROL,

View file

@ -0,0 +1,28 @@
from collections.abc import Iterator
from typing import Any, Literal, final
__all__ = ["Interpolation", "Template"]
@final
class Template: # TODO: consider making `Template` generic on `TypeVarTuple`
strings: tuple[str, ...]
interpolations: tuple[Interpolation, ...]
def __new__(cls, *args: str | Interpolation) -> Template: ...
def __iter__(self) -> Iterator[str | Interpolation]: ...
def __add__(self, other: Template | str) -> Template: ...
@property
def values(self) -> tuple[Any, ...]: ... # Tuple of interpolation values, which can have any type
@final
class Interpolation:
value: Any # TODO: consider making `Interpolation` generic in runtime
expression: str
conversion: Literal["a", "r", "s"] | None
format_spec: str
__match_args__ = ("value", "expression", "conversion", "format_spec")
def __new__(
cls, value: Any, expression: str, conversion: Literal["a", "r", "s"] | None = None, format_spec: str = ""
) -> Interpolation: ...

View file

@ -384,7 +384,7 @@ class SpooledTemporaryFile(IO[AnyStr], _SpooledTemporaryFileBase):
def write(self: SpooledTemporaryFile[bytes], s: ReadableBuffer) -> int: ... def write(self: SpooledTemporaryFile[bytes], s: ReadableBuffer) -> int: ...
@overload @overload
def write(self, s: AnyStr) -> int: ... def write(self, s: AnyStr) -> int: ...
@overload @overload # type: ignore[override]
def writelines(self: SpooledTemporaryFile[str], iterable: Iterable[str]) -> None: ... def writelines(self: SpooledTemporaryFile[str], iterable: Iterable[str]) -> None: ...
@overload @overload
def writelines(self: SpooledTemporaryFile[bytes], iterable: Iterable[ReadableBuffer]) -> None: ... def writelines(self: SpooledTemporaryFile[bytes], iterable: Iterable[ReadableBuffer]) -> None: ...

View file

@ -3,6 +3,7 @@ import sys
from _thread import _excepthook, _ExceptHookArgs, get_native_id as get_native_id from _thread import _excepthook, _ExceptHookArgs, get_native_id as get_native_id
from _typeshed import ProfileFunction, TraceFunction from _typeshed import ProfileFunction, TraceFunction
from collections.abc import Callable, Iterable, Mapping from collections.abc import Callable, Iterable, Mapping
from contextvars import ContextVar
from types import TracebackType from types import TracebackType
from typing import Any, TypeVar, final from typing import Any, TypeVar, final
from typing_extensions import deprecated from typing_extensions import deprecated
@ -76,6 +77,19 @@ class Thread:
@property @property
def ident(self) -> int | None: ... def ident(self) -> int | None: ...
daemon: bool daemon: bool
if sys.version_info >= (3, 14):
def __init__(
self,
group: None = None,
target: Callable[..., object] | None = None,
name: str | None = None,
args: Iterable[Any] = (),
kwargs: Mapping[str, Any] | None = None,
*,
daemon: bool | None = None,
context: ContextVar[Any] | None = None,
) -> None: ...
else:
def __init__( def __init__(
self, self,
group: None = None, group: None = None,
@ -86,6 +100,7 @@ class Thread:
*, *,
daemon: bool | None = None, daemon: bool | None = None,
) -> None: ... ) -> None: ...
def start(self) -> None: ... def start(self) -> None: ...
def run(self) -> None: ... def run(self) -> None: ...
def join(self, timeout: float | None = None) -> None: ... def join(self, timeout: float | None = None) -> None: ...
@ -116,6 +131,9 @@ class _RLock:
__enter__ = acquire __enter__ = acquire
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
if sys.version_info >= (3, 14):
def locked(self) -> bool: ...
RLock = _thread.RLock # Actually a function at runtime. RLock = _thread.RLock # Actually a function at runtime.
class Condition: class Condition:

View file

@ -286,7 +286,7 @@ else:
_W = TypeVar("_W", bound=Misc) _W = TypeVar("_W", bound=Misc)
# Events considered covariant because you should never assign to event.widget. # Events considered covariant because you should never assign to event.widget.
_W_co = TypeVar("_W_co", covariant=True, bound=Misc) _W_co = TypeVar("_W_co", covariant=True, bound=Misc, default=Misc)
class Event(Generic[_W_co]): class Event(Generic[_W_co]):
serial: int serial: int
@ -3736,6 +3736,7 @@ class PhotoImage(Image, _PhotoImageLike):
self, self,
data: ( data: (
str str
| bytes
| list[str] | list[str]
| list[list[str]] | list[list[str]]
| list[tuple[str, ...]] | list[tuple[str, ...]]
@ -3743,7 +3744,7 @@ class PhotoImage(Image, _PhotoImageLike):
| tuple[list[str], ...] | tuple[list[str], ...]
| tuple[tuple[str, ...], ...] | tuple[tuple[str, ...], ...]
), ),
to: tuple[int, int] | None = None, to: tuple[int, int] | tuple[int, int, int, int] | None = None,
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def read( def read(

View file

@ -562,7 +562,7 @@ class Notebook(Widget):
compound: tkinter._Compound = ..., compound: tkinter._Compound = ...,
underline: int = ..., underline: int = ...,
) -> None: ... ) -> None: ...
def forget(self, tab_id) -> None: ... def forget(self, tab_id) -> None: ... # type: ignore[override]
def hide(self, tab_id) -> None: ... def hide(self, tab_id) -> None: ...
def identify(self, x: int, y: int) -> str: ... def identify(self, x: int, y: int) -> str: ...
def index(self, tab_id): ... def index(self, tab_id): ...

View file

@ -78,6 +78,9 @@ if sys.version_info >= (3, 10):
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
__all__ += ["EXCLAMATION", "FSTRING_END", "FSTRING_MIDDLE", "FSTRING_START", "EXACT_TOKEN_TYPES"] __all__ += ["EXCLAMATION", "FSTRING_END", "FSTRING_MIDDLE", "FSTRING_START", "EXACT_TOKEN_TYPES"]
if sys.version_info >= (3, 14):
__all__ += ["TSTRING_START", "TSTRING_MIDDLE", "TSTRING_END"]
ENDMARKER: int ENDMARKER: int
NAME: int NAME: int
NUMBER: int NUMBER: int
@ -155,6 +158,11 @@ if sys.version_info >= (3, 12):
FSTRING_MIDDLE: int FSTRING_MIDDLE: int
FSTRING_START: int FSTRING_START: int
if sys.version_info >= (3, 14):
TSTRING_START: int
TSTRING_MIDDLE: int
TSTRING_END: int
def ISTERMINAL(x: int) -> bool: ... def ISTERMINAL(x: int) -> bool: ...
def ISNONTERMINAL(x: int) -> bool: ... def ISNONTERMINAL(x: int) -> bool: ...
def ISEOF(x: int) -> bool: ... def ISEOF(x: int) -> bool: ...

View file

@ -93,6 +93,9 @@ if sys.version_info >= (3, 12):
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
__all__ += ["TokenError", "open"] __all__ += ["TokenError", "open"]
if sys.version_info >= (3, 14):
__all__ += ["TSTRING_START", "TSTRING_MIDDLE", "TSTRING_END"]
cookie_re: Pattern[str] cookie_re: Pattern[str]
blank_re: Pattern[bytes] blank_re: Pattern[bytes]

View file

@ -1,10 +1,26 @@
import sys
from _typeshed import SupportsRead from _typeshed import SupportsRead
from collections.abc import Callable from collections.abc import Callable
from typing import Any from typing import Any, overload
from typing_extensions import deprecated
__all__ = ("loads", "load", "TOMLDecodeError") __all__ = ("loads", "load", "TOMLDecodeError")
class TOMLDecodeError(ValueError): ... if sys.version_info >= (3, 14):
class TOMLDecodeError(ValueError):
msg: str
doc: str
pos: int
lineno: int
colno: int
@overload
def __init__(self, msg: str, doc: str, pos: int) -> None: ...
@overload
@deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.")
def __init__(self, msg: str | type = ..., doc: str | type = ..., pos: int | type = ..., *args: Any) -> None: ...
else:
class TOMLDecodeError(ValueError): ...
def load(fp: SupportsRead[bytes], /, *, parse_float: Callable[[str], Any] = ...) -> dict[str, Any]: ... def load(fp: SupportsRead[bytes], /, *, parse_float: Callable[[str], Any] = ...) -> dict[str, Any]: ...
def loads(s: str, /, *, parse_float: Callable[[str], Any] = ...) -> dict[str, Any]: ... def loads(s: str, /, *, parse_float: Callable[[str], Any] = ...) -> dict[str, Any]: ...

View file

@ -27,6 +27,9 @@ __all__ = [
"walk_tb", "walk_tb",
] ]
if sys.version_info >= (3, 14):
__all__ += ["print_list"]
_FrameSummaryTuple: TypeAlias = tuple[str, int, str, str | None] _FrameSummaryTuple: TypeAlias = tuple[str, int, str, str | None]
def print_tb(tb: TracebackType | None, limit: int | None = None, file: SupportsWrite[str] | None = None) -> None: ... def print_tb(tb: TracebackType | None, limit: int | None = None, file: SupportsWrite[str] | None = None) -> None: ...
@ -81,8 +84,6 @@ def print_stack(f: FrameType | None = None, limit: int | None = None, file: Supp
def extract_tb(tb: TracebackType | None, limit: int | None = None) -> StackSummary: ... def extract_tb(tb: TracebackType | None, limit: int | None = None) -> StackSummary: ...
def extract_stack(f: FrameType | None = None, limit: int | None = None) -> StackSummary: ... def extract_stack(f: FrameType | None = None, limit: int | None = None) -> StackSummary: ...
def format_list(extracted_list: Iterable[FrameSummary | _FrameSummaryTuple]) -> list[str]: ... def format_list(extracted_list: Iterable[FrameSummary | _FrameSummaryTuple]) -> list[str]: ...
# undocumented
def print_list(extracted_list: Iterable[FrameSummary | _FrameSummaryTuple], file: SupportsWrite[str] | None = None) -> None: ... def print_list(extracted_list: Iterable[FrameSummary | _FrameSummaryTuple], file: SupportsWrite[str] | None = None) -> None: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):

View file

@ -1,5 +1,5 @@
import sys import sys
from _typeshed import MaybeNone, SupportsKeysAndGetItem from _typeshed import AnnotationForm, MaybeNone, SupportsKeysAndGetItem
from _typeshed.importlib import LoaderProtocol from _typeshed.importlib import LoaderProtocol
from collections.abc import ( from collections.abc import (
AsyncGenerator, AsyncGenerator,
@ -19,6 +19,9 @@ from importlib.machinery import ModuleSpec
from typing import Any, ClassVar, Literal, TypeVar, final, overload from typing import Any, ClassVar, Literal, TypeVar, final, overload
from typing_extensions import ParamSpec, Self, TypeAliasType, TypeVarTuple, deprecated from typing_extensions import ParamSpec, Self, TypeAliasType, TypeVarTuple, deprecated
if sys.version_info >= (3, 14):
from _typeshed import AnnotateFunc
__all__ = [ __all__ = [
"FunctionType", "FunctionType",
"LambdaType", "LambdaType",
@ -77,7 +80,9 @@ class FunctionType:
def __globals__(self) -> dict[str, Any]: ... def __globals__(self) -> dict[str, Any]: ...
__name__: str __name__: str
__qualname__: str __qualname__: str
__annotations__: dict[str, Any] __annotations__: dict[str, AnnotationForm]
if sys.version_info >= (3, 14):
__annotate__: AnnotateFunc | None
__kwdefaults__: dict[str, Any] | None __kwdefaults__: dict[str, Any] | None
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@property @property
@ -352,6 +357,10 @@ class ModuleType:
# Redeclaring `__doc__` here helps some type checkers understand that `__doc__` is available # Redeclaring `__doc__` here helps some type checkers understand that `__doc__` is available
# as an implicit global in all modules, similar to `__name__`, `__file__`, `__spec__`, etc. # as an implicit global in all modules, similar to `__name__`, `__file__`, `__spec__`, etc.
__doc__: str | None __doc__: str | None
__annotations__: dict[str, AnnotationForm]
if sys.version_info >= (3, 14):
__annotate__: AnnotateFunc | None
def __init__(self, name: str, doc: str | None = ...) -> None: ... def __init__(self, name: str, doc: str | None = ...) -> None: ...
# __getattr__ doesn't exist at runtime, # __getattr__ doesn't exist at runtime,
# but having it here in typeshed makes dynamic imports # but having it here in typeshed makes dynamic imports

View file

@ -23,6 +23,11 @@ from types import (
) )
from typing_extensions import Never as _Never, ParamSpec as _ParamSpec, deprecated from typing_extensions import Never as _Never, ParamSpec as _ParamSpec, deprecated
if sys.version_info >= (3, 14):
from _typeshed import EvaluateFunc
from annotationlib import Format
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
from types import UnionType from types import UnionType
@ -37,7 +42,6 @@ __all__ = [
"AsyncIterator", "AsyncIterator",
"Awaitable", "Awaitable",
"BinaryIO", "BinaryIO",
"ByteString",
"Callable", "Callable",
"ChainMap", "ChainMap",
"ClassVar", "ClassVar",
@ -106,6 +110,12 @@ __all__ = [
"runtime_checkable", "runtime_checkable",
] ]
if sys.version_info < (3, 14):
__all__ += ["ByteString"]
if sys.version_info >= (3, 14):
__all__ += ["evaluate_forward_ref"]
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__all__ += ["Concatenate", "ParamSpec", "ParamSpecArgs", "ParamSpecKwargs", "TypeAlias", "TypeGuard", "is_typeddict"] __all__ += ["Concatenate", "ParamSpec", "ParamSpecArgs", "ParamSpecKwargs", "TypeAlias", "TypeGuard", "is_typeddict"]
@ -132,6 +142,10 @@ if sys.version_info >= (3, 12):
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
__all__ += ["get_protocol_members", "is_protocol", "NoDefault", "TypeIs", "ReadOnly"] __all__ += ["get_protocol_members", "is_protocol", "NoDefault", "TypeIs", "ReadOnly"]
# We can't use this name here because it leads to issues with mypy, likely
# due to an import cycle. Below instead we use Any with a comment.
# from _typeshed import AnnotationForm
class Any: ... class Any: ...
class _Final: ... class _Final: ...
@ -141,9 +155,9 @@ class TypeVar:
@property @property
def __name__(self) -> str: ... def __name__(self) -> str: ...
@property @property
def __bound__(self) -> Any | None: ... def __bound__(self) -> Any | None: ... # AnnotationForm
@property @property
def __constraints__(self) -> tuple[Any, ...]: ... def __constraints__(self) -> tuple[Any, ...]: ... # AnnotationForm
@property @property
def __covariant__(self) -> bool: ... def __covariant__(self) -> bool: ...
@property @property
@ -153,46 +167,64 @@ class TypeVar:
def __infer_variance__(self) -> bool: ... def __infer_variance__(self) -> bool: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
@property @property
def __default__(self) -> Any: ... def __default__(self) -> Any: ... # AnnotationForm
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __new__( def __new__(
cls, cls,
name: str, name: str,
*constraints: Any, *constraints: Any, # AnnotationForm
bound: Any | None = None, bound: Any | None = None, # AnnotationForm
contravariant: bool = False, contravariant: bool = False,
covariant: bool = False, covariant: bool = False,
infer_variance: bool = False, infer_variance: bool = False,
default: Any = ..., default: Any = ..., # AnnotationForm
) -> Self: ... ) -> Self: ...
elif sys.version_info >= (3, 12): elif sys.version_info >= (3, 12):
def __new__( def __new__(
cls, cls,
name: str, name: str,
*constraints: Any, *constraints: Any, # AnnotationForm
bound: Any | None = None, bound: Any | None = None, # AnnotationForm
covariant: bool = False, covariant: bool = False,
contravariant: bool = False, contravariant: bool = False,
infer_variance: bool = False, infer_variance: bool = False,
) -> Self: ... ) -> Self: ...
elif sys.version_info >= (3, 11): elif sys.version_info >= (3, 11):
def __new__( def __new__(
cls, name: str, *constraints: Any, bound: Any | None = None, covariant: bool = False, contravariant: bool = False cls,
name: str,
*constraints: Any, # AnnotationForm
bound: Any | None = None, # AnnotationForm
covariant: bool = False,
contravariant: bool = False,
) -> Self: ... ) -> Self: ...
else: else:
def __init__( def __init__(
self, name: str, *constraints: Any, bound: Any | None = None, covariant: bool = False, contravariant: bool = False self,
name: str,
*constraints: Any, # AnnotationForm
bound: Any | None = None, # AnnotationForm
covariant: bool = False,
contravariant: bool = False,
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
def __or__(self, right: Any) -> _SpecialForm: ... def __or__(self, right: Any) -> _SpecialForm: ... # AnnotationForm
def __ror__(self, left: Any) -> _SpecialForm: ... def __ror__(self, left: Any) -> _SpecialForm: ... # AnnotationForm
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Any) -> Any: ... def __typing_subst__(self, arg: Any) -> Any: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
def has_default(self) -> bool: ... def has_default(self) -> bool: ...
if sys.version_info >= (3, 14):
@property
def evaluate_bound(self) -> EvaluateFunc | None: ...
@property
def evaluate_constraints(self) -> EvaluateFunc | None: ...
@property
def evaluate_default(self) -> EvaluateFunc | None: ...
# Used for an undocumented mypy feature. Does not exist at runtime. # Used for an undocumented mypy feature. Does not exist at runtime.
# Obsolete, use _typeshed._type_checker_internals.promote instead.
_promote = object() _promote = object()
# N.B. Keep this definition in sync with typing_extensions._SpecialForm # N.B. Keep this definition in sync with typing_extensions._SpecialForm
@ -232,10 +264,10 @@ if sys.version_info >= (3, 11):
def __name__(self) -> str: ... def __name__(self) -> str: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
@property @property
def __default__(self) -> Any: ... def __default__(self) -> Any: ... # AnnotationForm
def has_default(self) -> bool: ... def has_default(self) -> bool: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __new__(cls, name: str, *, default: Any = ...) -> Self: ... def __new__(cls, name: str, *, default: Any = ...) -> Self: ... # AnnotationForm
elif sys.version_info >= (3, 12): elif sys.version_info >= (3, 12):
def __new__(cls, name: str) -> Self: ... def __new__(cls, name: str) -> Self: ...
else: else:
@ -244,6 +276,9 @@ if sys.version_info >= (3, 11):
def __iter__(self) -> Any: ... def __iter__(self) -> Any: ...
def __typing_subst__(self, arg: Never) -> Never: ... def __typing_subst__(self, arg: Never) -> Never: ...
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
if sys.version_info >= (3, 14):
@property
def evaluate_default(self) -> EvaluateFunc | None: ...
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@final @final
@ -275,7 +310,7 @@ if sys.version_info >= (3, 10):
@property @property
def __name__(self) -> str: ... def __name__(self) -> str: ...
@property @property
def __bound__(self) -> Any | None: ... def __bound__(self) -> Any | None: ... # AnnotationForm
@property @property
def __covariant__(self) -> bool: ... def __covariant__(self) -> bool: ...
@property @property
@ -285,35 +320,45 @@ if sys.version_info >= (3, 10):
def __infer_variance__(self) -> bool: ... def __infer_variance__(self) -> bool: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
@property @property
def __default__(self) -> Any: ... def __default__(self) -> Any: ... # AnnotationForm
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __new__( def __new__(
cls, cls,
name: str, name: str,
*, *,
bound: Any | None = None, bound: Any | None = None, # AnnotationForm
contravariant: bool = False, contravariant: bool = False,
covariant: bool = False, covariant: bool = False,
infer_variance: bool = False, infer_variance: bool = False,
default: Any = ..., default: Any = ..., # AnnotationForm
) -> Self: ... ) -> Self: ...
elif sys.version_info >= (3, 12): elif sys.version_info >= (3, 12):
def __new__( def __new__(
cls, cls,
name: str, name: str,
*, *,
bound: Any | None = None, bound: Any | None = None, # AnnotationForm
contravariant: bool = False, contravariant: bool = False,
covariant: bool = False, covariant: bool = False,
infer_variance: bool = False, infer_variance: bool = False,
) -> Self: ... ) -> Self: ...
elif sys.version_info >= (3, 11): elif sys.version_info >= (3, 11):
def __new__( def __new__(
cls, name: str, *, bound: Any | None = None, contravariant: bool = False, covariant: bool = False cls,
name: str,
*,
bound: Any | None = None, # AnnotationForm
contravariant: bool = False,
covariant: bool = False,
) -> Self: ... ) -> Self: ...
else: else:
def __init__( def __init__(
self, name: str, *, bound: Any | None = None, contravariant: bool = False, covariant: bool = False self,
name: str,
*,
bound: Any | None = None, # AnnotationForm
contravariant: bool = False,
covariant: bool = False,
) -> None: ... ) -> None: ...
@property @property
@ -328,13 +373,16 @@ if sys.version_info >= (3, 10):
def __ror__(self, left: Any) -> _SpecialForm: ... def __ror__(self, left: Any) -> _SpecialForm: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def has_default(self) -> bool: ... def has_default(self) -> bool: ...
if sys.version_info >= (3, 14):
@property
def evaluate_default(self) -> EvaluateFunc | None: ...
Concatenate: _SpecialForm Concatenate: _SpecialForm
TypeAlias: _SpecialForm TypeAlias: _SpecialForm
TypeGuard: _SpecialForm TypeGuard: _SpecialForm
class NewType: class NewType:
def __init__(self, name: str, tp: Any) -> None: ... def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
@staticmethod @staticmethod
def __call__(x: _T, /) -> _T: ... def __call__(x: _T, /) -> _T: ...
@ -531,6 +579,7 @@ class Coroutine(Awaitable[_ReturnT_nd_co], Generic[_YieldT_co, _SendT_nd_contra,
# NOTE: This type does not exist in typing.py or PEP 484 but mypy needs it to exist. # NOTE: This type does not exist in typing.py or PEP 484 but mypy needs it to exist.
# The parameters correspond to Generator, but the 4th is the original type. # The parameters correspond to Generator, but the 4th is the original type.
# Obsolete, use _typeshed._type_checker_internals.AwaitableGenerator instead.
@type_check_only @type_check_only
class AwaitableGenerator( class AwaitableGenerator(
Awaitable[_ReturnT_nd_co], Awaitable[_ReturnT_nd_co],
@ -858,13 +907,25 @@ _get_type_hints_obj_allowed_types: typing_extensions.TypeAlias = ( # noqa: Y042
| MethodDescriptorType | MethodDescriptorType
) )
def get_type_hints( if sys.version_info >= (3, 14):
def get_type_hints(
obj: _get_type_hints_obj_allowed_types, obj: _get_type_hints_obj_allowed_types,
globalns: dict[str, Any] | None = None, globalns: dict[str, Any] | None = None,
localns: Mapping[str, Any] | None = None, localns: Mapping[str, Any] | None = None,
include_extras: bool = False, include_extras: bool = False,
) -> dict[str, Any]: ... *,
def get_args(tp: Any) -> tuple[Any, ...]: ... format: Format | None = None,
) -> dict[str, Any]: ... # AnnotationForm
else:
def get_type_hints(
obj: _get_type_hints_obj_allowed_types,
globalns: dict[str, Any] | None = None,
localns: Mapping[str, Any] | None = None,
include_extras: bool = False,
) -> dict[str, Any]: ... # AnnotationForm
def get_args(tp: Any) -> tuple[Any, ...]: ... # AnnotationForm
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@overload @overload
@ -875,7 +936,7 @@ if sys.version_info >= (3, 10):
@overload @overload
def get_origin(tp: GenericAlias) -> type: ... def get_origin(tp: GenericAlias) -> type: ...
@overload @overload
def get_origin(tp: Any) -> Any | None: ... def get_origin(tp: Any) -> Any | None: ... # AnnotationForm
@overload @overload
def cast(typ: type[_T], val: Any) -> _T: ... def cast(typ: type[_T], val: Any) -> _T: ...
@overload @overload
@ -886,7 +947,7 @@ def cast(typ: object, val: Any) -> Any: ...
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
def reveal_type(obj: _T, /) -> _T: ... def reveal_type(obj: _T, /) -> _T: ...
def assert_never(arg: Never, /) -> Never: ... def assert_never(arg: Never, /) -> Never: ...
def assert_type(val: _T, typ: Any, /) -> _T: ... def assert_type(val: _T, typ: Any, /) -> _T: ... # AnnotationForm
def clear_overloads() -> None: ... def clear_overloads() -> None: ...
def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ... def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ...
def dataclass_transform( def dataclass_transform(
@ -901,6 +962,7 @@ if sys.version_info >= (3, 11):
# Type constructors # Type constructors
# Obsolete, will be changed to a function. Use _typeshed._type_checker_internals.NamedTupleFallback instead.
class NamedTuple(tuple[Any, ...]): class NamedTuple(tuple[Any, ...]):
_field_defaults: ClassVar[dict[str, Any]] _field_defaults: ClassVar[dict[str, Any]]
_fields: ClassVar[tuple[str, ...]] _fields: ClassVar[tuple[str, ...]]
@ -925,6 +987,7 @@ class NamedTuple(tuple[Any, ...]):
# Internal mypy fallback type for all typed dicts (does not exist at runtime) # Internal mypy fallback type for all typed dicts (does not exist at runtime)
# N.B. Keep this mostly in sync with typing_extensions._TypedDict/mypy_extensions._TypedDict # N.B. Keep this mostly in sync with typing_extensions._TypedDict/mypy_extensions._TypedDict
# Obsolete, use _typeshed._type_checker_internals.TypedDictFallback instead.
@type_check_only @type_check_only
class _TypedDict(Mapping[str, object], metaclass=ABCMeta): class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
__total__: ClassVar[bool] __total__: ClassVar[bool]
@ -960,12 +1023,26 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
# supposedly incompatible definitions of __or__ and __ior__ # supposedly incompatible definitions of __or__ and __ior__
def __ior__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ... # type: ignore[misc] def __ior__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ... # type: ignore[misc]
@final if sys.version_info >= (3, 14):
class ForwardRef(_Final): from annotationlib import ForwardRef as ForwardRef
def evaluate_forward_ref(
forward_ref: ForwardRef,
*,
owner: object = None,
globals: dict[str, Any] | None = None,
locals: Mapping[str, Any] | None = None,
type_params: tuple[TypeVar, ParamSpec, TypeVarTuple] | None = None,
format: Format | None = None,
) -> Any: ... # AnnotationForm
else:
@final
class ForwardRef(_Final):
__forward_arg__: str __forward_arg__: str
__forward_code__: CodeType __forward_code__: CodeType
__forward_evaluated__: bool __forward_evaluated__: bool
__forward_value__: Any | None __forward_value__: Any | None # AnnotationForm
__forward_is_argument__: bool __forward_is_argument__: bool
__forward_is_class__: bool __forward_is_class__: bool
__forward_module__: Any | None __forward_module__: Any | None
@ -981,7 +1058,7 @@ class ForwardRef(_Final):
) )
def _evaluate( def _evaluate(
self, globalns: dict[str, Any] | None, localns: Mapping[str, Any] | None, *, recursive_guard: frozenset[str] self, globalns: dict[str, Any] | None, localns: Mapping[str, Any] | None, *, recursive_guard: frozenset[str]
) -> Any | None: ... ) -> Any | None: ... # AnnotationForm
@overload @overload
def _evaluate( def _evaluate(
self, self,
@ -990,7 +1067,7 @@ class ForwardRef(_Final):
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...], type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...],
*, *,
recursive_guard: frozenset[str], recursive_guard: frozenset[str],
) -> Any | None: ... ) -> Any | None: ... # AnnotationForm
elif sys.version_info >= (3, 12): elif sys.version_info >= (3, 12):
def _evaluate( def _evaluate(
self, self,
@ -999,11 +1076,11 @@ class ForwardRef(_Final):
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] | None = None, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] | None = None,
*, *,
recursive_guard: frozenset[str], recursive_guard: frozenset[str],
) -> Any | None: ... ) -> Any | None: ... # AnnotationForm
else: else:
def _evaluate( def _evaluate(
self, globalns: dict[str, Any] | None, localns: Mapping[str, Any] | None, recursive_guard: frozenset[str] self, globalns: dict[str, Any] | None, localns: Mapping[str, Any] | None, recursive_guard: frozenset[str]
) -> Any | None: ... ) -> Any | None: ... # AnnotationForm
def __eq__(self, other: object) -> bool: ... def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ... def __hash__(self) -> int: ...
@ -1022,19 +1099,22 @@ if sys.version_info >= (3, 12):
class TypeAliasType: class TypeAliasType:
def __new__(cls, name: str, value: Any, *, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = ()) -> Self: ... def __new__(cls, name: str, value: Any, *, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = ()) -> Self: ...
@property @property
def __value__(self) -> Any: ... def __value__(self) -> Any: ... # AnnotationForm
@property @property
def __type_params__(self) -> tuple[TypeVar | ParamSpec | TypeVarTuple, ...]: ... def __type_params__(self) -> tuple[TypeVar | ParamSpec | TypeVarTuple, ...]: ...
@property @property
def __parameters__(self) -> tuple[Any, ...]: ... def __parameters__(self) -> tuple[Any, ...]: ... # AnnotationForm
@property @property
def __name__(self) -> str: ... def __name__(self) -> str: ...
# It's writable on types, but not on instances of TypeAliasType. # It's writable on types, but not on instances of TypeAliasType.
@property @property
def __module__(self) -> str | None: ... # type: ignore[override] def __module__(self) -> str | None: ... # type: ignore[override]
def __getitem__(self, parameters: Any) -> GenericAlias: ... def __getitem__(self, parameters: Any) -> GenericAlias: ... # AnnotationForm
def __or__(self, right: Any) -> _SpecialForm: ... def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ... def __ror__(self, left: Any) -> _SpecialForm: ...
if sys.version_info >= (3, 14):
@property
def evaluate_value(self) -> EvaluateFunc: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def is_protocol(tp: type, /) -> bool: ... def is_protocol(tp: type, /) -> bool: ...

View file

@ -2,7 +2,7 @@ import abc
import enum import enum
import sys import sys
from _collections_abc import dict_items, dict_keys, dict_values from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import IdentityFunction, Incomplete, Unused from _typeshed import AnnotationForm, IdentityFunction, Incomplete, Unused
from collections.abc import ( from collections.abc import (
AsyncGenerator as AsyncGenerator, AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable, AsyncIterable as AsyncIterable,
@ -241,7 +241,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
__mutable_keys__: ClassVar[frozenset[str]] __mutable_keys__: ClassVar[frozenset[str]]
# PEP 728 # PEP 728
__closed__: ClassVar[bool] __closed__: ClassVar[bool]
__extra_items__: ClassVar[Any] __extra_items__: ClassVar[AnnotationForm]
def copy(self) -> Self: ... def copy(self) -> Self: ...
# Using Never so that only calls using mypy plugin hook that specialize the signature # Using Never so that only calls using mypy plugin hook that specialize the signature
# can go through. # can go through.
@ -267,13 +267,14 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
OrderedDict = _Alias() OrderedDict = _Alias()
def get_type_hints( if sys.version_info >= (3, 13):
obj: Callable[..., Any], from typing import get_type_hints as get_type_hints
globalns: dict[str, Any] | None = None, else:
localns: Mapping[str, Any] | None = None, def get_type_hints(
include_extras: bool = False, obj: Any, globalns: dict[str, Any] | None = None, localns: Mapping[str, Any] | None = None, include_extras: bool = False
) -> dict[str, Any]: ... ) -> dict[str, AnnotationForm]: ...
def get_args(tp: Any) -> tuple[Any, ...]: ...
def get_args(tp: AnnotationForm) -> tuple[AnnotationForm, ...]: ...
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@overload @overload
@ -284,7 +285,7 @@ def get_origin(tp: GenericAlias) -> type: ...
@overload @overload
def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ... def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ...
@overload @overload
def get_origin(tp: Any) -> Any | None: ... def get_origin(tp: AnnotationForm) -> AnnotationForm | None: ...
Annotated: _SpecialForm Annotated: _SpecialForm
_AnnotatedAlias: Any # undocumented _AnnotatedAlias: Any # undocumented
@ -340,7 +341,7 @@ else:
Never: _SpecialForm Never: _SpecialForm
def reveal_type(obj: _T, /) -> _T: ... def reveal_type(obj: _T, /) -> _T: ...
def assert_never(arg: Never, /) -> Never: ... def assert_never(arg: Never, /) -> Never: ...
def assert_type(val: _T, typ: Any, /) -> _T: ... def assert_type(val: _T, typ: AnnotationForm, /) -> _T: ...
def clear_overloads() -> None: ... def clear_overloads() -> None: ...
def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ... def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ...
@ -373,7 +374,7 @@ else:
def _replace(self, **kwargs: Any) -> Self: ... def _replace(self, **kwargs: Any) -> Self: ...
class NewType: class NewType:
def __init__(self, name: str, tp: Any) -> None: ... def __init__(self, name: str, tp: AnnotationForm) -> None: ...
def __call__(self, obj: _T, /) -> _T: ... def __call__(self, obj: _T, /) -> _T: ...
__supertype__: type | NewType __supertype__: type | NewType
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@ -480,9 +481,9 @@ else:
@property @property
def __name__(self) -> str: ... def __name__(self) -> str: ...
@property @property
def __bound__(self) -> Any | None: ... def __bound__(self) -> AnnotationForm | None: ...
@property @property
def __constraints__(self) -> tuple[Any, ...]: ... def __constraints__(self) -> tuple[AnnotationForm, ...]: ...
@property @property
def __covariant__(self) -> bool: ... def __covariant__(self) -> bool: ...
@property @property
@ -490,15 +491,15 @@ else:
@property @property
def __infer_variance__(self) -> bool: ... def __infer_variance__(self) -> bool: ...
@property @property
def __default__(self) -> Any: ... def __default__(self) -> AnnotationForm: ...
def __init__( def __init__(
self, self,
name: str, name: str,
*constraints: Any, *constraints: AnnotationForm,
bound: Any | None = None, bound: AnnotationForm | None = None,
covariant: bool = False, covariant: bool = False,
contravariant: bool = False, contravariant: bool = False,
default: Any = ..., default: AnnotationForm = ...,
infer_variance: bool = False, infer_variance: bool = False,
) -> None: ... ) -> None: ...
def has_default(self) -> bool: ... def has_default(self) -> bool: ...
@ -514,7 +515,7 @@ else:
@property @property
def __name__(self) -> str: ... def __name__(self) -> str: ...
@property @property
def __bound__(self) -> Any | None: ... def __bound__(self) -> AnnotationForm | None: ...
@property @property
def __covariant__(self) -> bool: ... def __covariant__(self) -> bool: ...
@property @property
@ -522,15 +523,15 @@ else:
@property @property
def __infer_variance__(self) -> bool: ... def __infer_variance__(self) -> bool: ...
@property @property
def __default__(self) -> Any: ... def __default__(self) -> AnnotationForm: ...
def __init__( def __init__(
self, self,
name: str, name: str,
*, *,
bound: None | type[Any] | str = None, bound: None | AnnotationForm | str = None,
contravariant: bool = False, contravariant: bool = False,
covariant: bool = False, covariant: bool = False,
default: Any = ..., default: AnnotationForm = ...,
) -> None: ... ) -> None: ...
@property @property
def args(self) -> ParamSpecArgs: ... def args(self) -> ParamSpecArgs: ...
@ -547,8 +548,8 @@ else:
@property @property
def __name__(self) -> str: ... def __name__(self) -> str: ...
@property @property
def __default__(self) -> Any: ... def __default__(self) -> AnnotationForm: ...
def __init__(self, name: str, *, default: Any = ...) -> None: ... def __init__(self, name: str, *, default: AnnotationForm = ...) -> None: ...
def __iter__(self) -> Any: ... # Unpack[Self] def __iter__(self) -> Any: ... # Unpack[Self]
def has_default(self) -> bool: ... def has_default(self) -> bool: ...
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
@ -563,23 +564,23 @@ else:
@final @final
class TypeAliasType: class TypeAliasType:
def __init__( def __init__(
self, name: str, value: Any, *, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = () self, name: str, value: AnnotationForm, *, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = ()
) -> None: ... # value is a type expression ) -> None: ...
@property @property
def __value__(self) -> Any: ... # a type expression def __value__(self) -> AnnotationForm: ...
@property @property
def __type_params__(self) -> tuple[TypeVar | ParamSpec | TypeVarTuple, ...]: ... def __type_params__(self) -> tuple[TypeVar | ParamSpec | TypeVarTuple, ...]: ...
@property @property
# `__parameters__` can include special forms if a `TypeVarTuple` was # `__parameters__` can include special forms if a `TypeVarTuple` was
# passed as a `type_params` element to the constructor method. # passed as a `type_params` element to the constructor method.
def __parameters__(self) -> tuple[TypeVar | ParamSpec | Any, ...]: ... def __parameters__(self) -> tuple[TypeVar | ParamSpec | AnnotationForm, ...]: ...
@property @property
def __name__(self) -> str: ... def __name__(self) -> str: ...
# It's writable on types, but not on instances of TypeAliasType. # It's writable on types, but not on instances of TypeAliasType.
@property @property
def __module__(self) -> str | None: ... # type: ignore[override] def __module__(self) -> str | None: ... # type: ignore[override]
# Returns typing._GenericAlias, which isn't stubbed. # Returns typing._GenericAlias, which isn't stubbed.
def __getitem__(self, parameters: Incomplete | tuple[Incomplete, ...]) -> Any: ... def __getitem__(self, parameters: Incomplete | tuple[Incomplete, ...]) -> AnnotationForm: ...
def __init_subclass__(cls, *args: Unused, **kwargs: Unused) -> NoReturn: ... def __init_subclass__(cls, *args: Unused, **kwargs: Unused) -> NoReturn: ...
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
def __or__(self, right: Any) -> _SpecialForm: ... def __or__(self, right: Any) -> _SpecialForm: ...
@ -600,21 +601,69 @@ NoExtraItems: _NoExtraItemsType
# PEP 747 # PEP 747
TypeForm: _SpecialForm TypeForm: _SpecialForm
class Format(enum.IntEnum):
VALUE = 1
FORWARDREF = 2
STRING = 3
# PEP 649/749 # PEP 649/749
def get_annotations( if sys.version_info >= (3, 14):
obj: Callable[..., object] | type[object] | ModuleType, # any callable, class, or module from typing import evaluate_forward_ref as evaluate_forward_ref
from annotationlib import Format as Format, get_annotations as get_annotations
else:
class Format(enum.IntEnum):
VALUE = 1
VALUE_WITH_FAKE_GLOBALS = 2
FORWARDREF = 3
STRING = 4
@overload
def get_annotations(
obj: Any, # any object with __annotations__ or __annotate__
*,
globals: Mapping[str, Any] | None = None, # value types depend on the key
locals: Mapping[str, Any] | None = None, # value types depend on the key
eval_str: bool = False,
format: Literal[Format.STRING],
) -> dict[str, str]: ...
@overload
def get_annotations(
obj: Any, # any object with __annotations__ or __annotate__
*,
globals: Mapping[str, Any] | None = None, # value types depend on the key
locals: Mapping[str, Any] | None = None, # value types depend on the key
eval_str: bool = False,
format: Literal[Format.FORWARDREF],
) -> dict[str, AnnotationForm | ForwardRef]: ...
@overload
def get_annotations(
obj: Any, # any object with __annotations__ or __annotate__
*, *,
globals: Mapping[str, Any] | None = None, # value types depend on the key globals: Mapping[str, Any] | None = None, # value types depend on the key
locals: Mapping[str, Any] | None = None, # value types depend on the key locals: Mapping[str, Any] | None = None, # value types depend on the key
eval_str: bool = False, eval_str: bool = False,
format: Format = Format.VALUE, # noqa: Y011 format: Format = Format.VALUE, # noqa: Y011
) -> dict[str, Any]: ... # values are type expressions ) -> dict[str, AnnotationForm]: ...
def evaluate_forward_ref( @overload
def evaluate_forward_ref(
forward_ref: ForwardRef,
*,
owner: Callable[..., object] | type[object] | ModuleType | None = None, # any callable, class, or module
globals: Mapping[str, Any] | None = None, # value types depend on the key
locals: Mapping[str, Any] | None = None, # value types depend on the key
type_params: Iterable[TypeVar | ParamSpec | TypeVarTuple] | None = None,
format: Literal[Format.STRING],
_recursive_guard: Container[str] = ...,
) -> str: ...
@overload
def evaluate_forward_ref(
forward_ref: ForwardRef,
*,
owner: Callable[..., object] | type[object] | ModuleType | None = None, # any callable, class, or module
globals: Mapping[str, Any] | None = None, # value types depend on the key
locals: Mapping[str, Any] | None = None, # value types depend on the key
type_params: Iterable[TypeVar | ParamSpec | TypeVarTuple] | None = None,
format: Literal[Format.FORWARDREF],
_recursive_guard: Container[str] = ...,
) -> AnnotationForm | ForwardRef: ...
@overload
def evaluate_forward_ref(
forward_ref: ForwardRef, forward_ref: ForwardRef,
*, *,
owner: Callable[..., object] | type[object] | ModuleType | None = None, # any callable, class, or module owner: Callable[..., object] | type[object] | ModuleType | None = None, # any callable, class, or module
@ -623,4 +672,4 @@ def evaluate_forward_ref(
type_params: Iterable[TypeVar | ParamSpec | TypeVarTuple] | None = None, type_params: Iterable[TypeVar | ParamSpec | TypeVarTuple] | None = None,
format: Format = Format.VALUE, # noqa: Y011 format: Format = Format.VALUE, # noqa: Y011
_recursive_guard: Container[str] = ..., _recursive_guard: Container[str] = ...,
) -> Any: ... # str if format is Format.STRING, otherwise a type expression ) -> AnnotationForm: ...

View file

@ -18,6 +18,7 @@ _T = TypeVar("_T")
_S = TypeVar("_S", bound=SupportsSub[Any, Any]) _S = TypeVar("_S", bound=SupportsSub[Any, Any])
_E = TypeVar("_E", bound=BaseException) _E = TypeVar("_E", bound=BaseException)
_FT = TypeVar("_FT", bound=Callable[..., Any]) _FT = TypeVar("_FT", bound=Callable[..., Any])
_SB = TypeVar("_SB", str, bytes, bytearray)
_P = ParamSpec("_P") _P = ParamSpec("_P")
DIFF_OMITTED: Final[str] DIFF_OMITTED: Final[str]
@ -289,6 +290,16 @@ class TestCase:
# Runtime has *args, **kwargs, but will error if any are supplied # Runtime has *args, **kwargs, but will error if any are supplied
def __init_subclass__(cls, *args: Never, **kwargs: Never) -> None: ... def __init_subclass__(cls, *args: Never, **kwargs: Never) -> None: ...
if sys.version_info >= (3, 14):
def assertIsSubclass(self, cls: type, superclass: type | tuple[type, ...], msg: Any = None) -> None: ...
def assertNotIsSubclass(self, cls: type, superclass: type | tuple[type, ...], msg: Any = None) -> None: ...
def assertHasAttr(self, obj: object, name: str, msg: Any = None) -> None: ...
def assertNotHasAttr(self, obj: object, name: str, msg: Any = None) -> None: ...
def assertStartsWith(self, s: _SB, prefix: _SB | tuple[_SB, ...], msg: Any = None) -> None: ...
def assertNotStartsWith(self, s: _SB, prefix: _SB | tuple[_SB, ...], msg: Any = None) -> None: ...
def assertEndsWith(self, s: _SB, suffix: _SB | tuple[_SB, ...], msg: Any = None) -> None: ...
def assertNotEndsWith(self, s: _SB, suffix: _SB | tuple[_SB, ...], msg: Any = None) -> None: ...
class FunctionTestCase(TestCase): class FunctionTestCase(TestCase):
def __init__( def __init__(
self, self,

View file

@ -7,7 +7,7 @@ from http.client import HTTPConnection, HTTPMessage, HTTPResponse
from http.cookiejar import CookieJar from http.cookiejar import CookieJar
from re import Pattern from re import Pattern
from typing import IO, Any, ClassVar, NoReturn, Protocol, TypeVar, overload from typing import IO, Any, ClassVar, NoReturn, Protocol, TypeVar, overload
from typing_extensions import TypeAlias from typing_extensions import TypeAlias, deprecated
from urllib.error import HTTPError as HTTPError from urllib.error import HTTPError as HTTPError
from urllib.response import addclosehook, addinfourl from urllib.response import addclosehook, addinfourl
@ -43,10 +43,10 @@ __all__ = [
"getproxies", "getproxies",
"urlretrieve", "urlretrieve",
"urlcleanup", "urlcleanup",
"URLopener",
"FancyURLopener",
"HTTPSHandler", "HTTPSHandler",
] ]
if sys.version_info < (3, 14):
__all__ += ["URLopener", "FancyURLopener"]
_T = TypeVar("_T") _T = TypeVar("_T")
_UrlopenRet: TypeAlias = Any _UrlopenRet: TypeAlias = Any
@ -72,9 +72,14 @@ else:
def install_opener(opener: OpenerDirector) -> None: ... def install_opener(opener: OpenerDirector) -> None: ...
def build_opener(*handlers: BaseHandler | Callable[[], BaseHandler]) -> OpenerDirector: ... def build_opener(*handlers: BaseHandler | Callable[[], BaseHandler]) -> OpenerDirector: ...
if sys.platform == "win32": if sys.version_info >= (3, 14):
from nturl2path import pathname2url as pathname2url, url2pathname as url2pathname def url2pathname(url: str, *, require_scheme: bool = False, resolve_host: bool = False) -> str: ...
def pathname2url(pathname: str, *, add_scheme: bool = False) -> str: ...
else: else:
if sys.platform == "win32":
from nturl2path import pathname2url as pathname2url, url2pathname as url2pathname
else:
def url2pathname(pathname: str) -> str: ... def url2pathname(pathname: str) -> str: ...
def pathname2url(pathname: str) -> str: ... def pathname2url(pathname: str) -> str: ...
@ -318,7 +323,9 @@ def urlretrieve(
) -> tuple[str, HTTPMessage]: ... ) -> tuple[str, HTTPMessage]: ...
def urlcleanup() -> None: ... def urlcleanup() -> None: ...
class URLopener: if sys.version_info < (3, 14):
@deprecated("Deprecated since Python 3.3; Removed in 3.14; Use newer urlopen functions and methods.")
class URLopener:
version: ClassVar[str] version: ClassVar[str]
def __init__(self, proxies: dict[str, str] | None = None, **x509: str) -> None: ... def __init__(self, proxies: dict[str, str] | None = None, **x509: str) -> None: ...
def open(self, fullurl: str, data: ReadableBuffer | None = None) -> _UrlopenRet: ... def open(self, fullurl: str, data: ReadableBuffer | None = None) -> _UrlopenRet: ...
@ -348,7 +355,8 @@ class URLopener:
def open_unknown_proxy(self, proxy: str, fullurl: str, data: ReadableBuffer | None = None) -> None: ... # undocumented def open_unknown_proxy(self, proxy: str, fullurl: str, data: ReadableBuffer | None = None) -> None: ... # undocumented
def __del__(self) -> None: ... def __del__(self) -> None: ...
class FancyURLopener(URLopener): @deprecated("Deprecated since Python 3.3; Removed in 3.14; Use newer urlopen functions and methods.")
class FancyURLopener(URLopener):
def prompt_user_passwd(self, host: str, realm: str) -> tuple[str, str]: ... def prompt_user_passwd(self, host: str, realm: str) -> tuple[str, str]: ...
def get_user_passwd(self, host: str, realm: str, clear_cache: int = 0) -> tuple[str, str]: ... # undocumented def get_user_passwd(self, host: str, realm: str, clear_cache: int = 0) -> tuple[str, str]: ... # undocumented
def http_error_301( def http_error_301(

View file

@ -1,7 +1,8 @@
import builtins import builtins
import sys import sys
from enum import Enum from enum import Enum
from typing_extensions import TypeAlias from typing import Final
from typing_extensions import LiteralString, TypeAlias
_FieldsType: TypeAlias = tuple[int, int, int, int, int, int] _FieldsType: TypeAlias = tuple[int, int, int, int, int, int]
@ -67,6 +68,11 @@ class UUID:
def getnode() -> int: ... def getnode() -> int: ...
def uuid1(node: int | None = None, clock_seq: int | None = None) -> UUID: ... def uuid1(node: int | None = None, clock_seq: int | None = None) -> UUID: ...
if sys.version_info >= (3, 14):
def uuid6(node: int | None = None, clock_seq: int | None = None) -> UUID: ...
def uuid7() -> UUID: ...
def uuid8(a: int | None = None, b: int | None = None, c: int | None = None) -> UUID: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
def uuid3(namespace: UUID, name: str | bytes) -> UUID: ... def uuid3(namespace: UUID, name: str | bytes) -> UUID: ...
@ -81,14 +87,18 @@ if sys.version_info >= (3, 12):
else: else:
def uuid5(namespace: UUID, name: str) -> UUID: ... def uuid5(namespace: UUID, name: str) -> UUID: ...
NAMESPACE_DNS: UUID if sys.version_info >= (3, 14):
NAMESPACE_URL: UUID NIL: Final[UUID]
NAMESPACE_OID: UUID MAX: Final[UUID]
NAMESPACE_X500: UUID
RESERVED_NCS: str NAMESPACE_DNS: Final[UUID]
RFC_4122: str NAMESPACE_URL: Final[UUID]
RESERVED_MICROSOFT: str NAMESPACE_OID: Final[UUID]
RESERVED_FUTURE: str NAMESPACE_X500: Final[UUID]
RESERVED_NCS: Final[LiteralString]
RFC_4122: Final[LiteralString]
RESERVED_MICROSOFT: Final[LiteralString]
RESERVED_FUTURE: Final[LiteralString]
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
def main() -> None: ... def main() -> None: ...