Sync vendored typeshed stubs (#12899)

Close and reopen this PR to trigger CI

Co-authored-by: typeshedbot <>
This commit is contained in:
github-actions[bot] 2024-08-14 18:11:23 -07:00 committed by GitHub
parent e4c2859c0f
commit ac7b1770e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
41 changed files with 653 additions and 172 deletions

View File

@ -1 +1 @@
4ef2d66663fc080fefa379e6ae5fc45d4f8b54eb 1ace5718deaf3041f8e3d1dc9c9e8a8e830e517f

View File

@ -753,9 +753,11 @@ class Constant(expr):
__match_args__ = ("value", "kind") __match_args__ = ("value", "kind")
value: Any # None, str, bytes, bool, int, float, complex, Ellipsis value: Any # None, str, bytes, bool, int, float, complex, Ellipsis
kind: str | None kind: str | None
# Aliases for value, for backwards compatibility if sys.version_info < (3, 14):
s: Any # Aliases for value, for backwards compatibility
n: int | float | complex s: Any
n: int | float | complex
def __init__(self, value: Any, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, value: Any, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
class NamedExpr(expr): class NamedExpr(expr):

View File

@ -1,13 +1,12 @@
import sys import sys
from abc import abstractmethod from abc import abstractmethod
from types import MappingProxyType from types import MappingProxyType
from typing import ( # noqa: Y022,Y038,Y057 from typing import ( # noqa: Y022,Y038
AbstractSet as Set, AbstractSet as Set,
AsyncGenerator as AsyncGenerator, AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable, AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator, AsyncIterator as AsyncIterator,
Awaitable as Awaitable, Awaitable as Awaitable,
ByteString as ByteString,
Callable as Callable, Callable as Callable,
Collection as Collection, Collection as Collection,
Container as Container, Container as Container,
@ -59,8 +58,12 @@ __all__ = [
"ValuesView", "ValuesView",
"Sequence", "Sequence",
"MutableSequence", "MutableSequence",
"ByteString",
] ]
if sys.version_info < (3, 14):
from typing import ByteString as ByteString # noqa: Y057
__all__ += ["ByteString"]
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
__all__ += ["Buffer"] __all__ += ["Buffer"]

View File

@ -51,8 +51,8 @@ class _CDataMeta(type):
# By default mypy complains about the following two methods, because strictly speaking cls # By default mypy complains about the following two methods, because strictly speaking cls
# might not be a Type[_CT]. However this can never actually happen, because the only class that # might not be a Type[_CT]. However this can never actually happen, because the only class that
# uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here. # uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here.
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
class _CData(metaclass=_CDataMeta): class _CData(metaclass=_CDataMeta):
_b_base_: int _b_base_: int

View File

@ -357,7 +357,17 @@ class Action(_AttributeHolder):
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
class BooleanOptionalAction(Action): class BooleanOptionalAction(Action):
if sys.version_info >= (3, 13): if sys.version_info >= (3, 14):
def __init__(
self,
option_strings: Sequence[str],
dest: str,
default: bool | None = None,
required: bool = False,
help: str | None = None,
deprecated: bool = False,
) -> None: ...
elif sys.version_info >= (3, 13):
@overload @overload
def __init__( def __init__(
self, self,

View File

@ -10,27 +10,28 @@ class _ABC(type):
if sys.version_info >= (3, 9): if sys.version_info >= (3, 9):
def __init__(cls, *args: Unused) -> None: ... def __init__(cls, *args: Unused) -> None: ...
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14") if sys.version_info < (3, 14):
class Num(Constant, metaclass=_ABC): @deprecated("Replaced by ast.Constant; removed in Python 3.14")
value: int | float | complex class Num(Constant, metaclass=_ABC):
value: int | float | complex
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14") @deprecated("Replaced by ast.Constant; removed in Python 3.14")
class Str(Constant, metaclass=_ABC): class Str(Constant, metaclass=_ABC):
value: str value: str
# Aliases for value, for backwards compatibility # Aliases for value, for backwards compatibility
s: str s: str
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14") @deprecated("Replaced by ast.Constant; removed in Python 3.14")
class Bytes(Constant, metaclass=_ABC): class Bytes(Constant, metaclass=_ABC):
value: bytes value: bytes
# Aliases for value, for backwards compatibility # Aliases for value, for backwards compatibility
s: bytes s: bytes
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14") @deprecated("Replaced by ast.Constant; removed in Python 3.14")
class NameConstant(Constant, metaclass=_ABC): ... class NameConstant(Constant, metaclass=_ABC): ...
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14") @deprecated("Replaced by ast.Constant; removed in Python 3.14")
class Ellipsis(Constant, metaclass=_ABC): ... class Ellipsis(Constant, metaclass=_ABC): ...
if sys.version_info >= (3, 9): if sys.version_info >= (3, 9):
class slice(AST): ... class slice(AST): ...

View File

@ -151,13 +151,13 @@ if sys.version_info >= (3, 10):
@overload @overload
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap] def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap]
@overload @overload
def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[overload-overlap] def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ...
@overload @overload
def gather( # type: ignore[overload-overlap] def gather(
coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ...
@overload @overload
def gather( # type: ignore[overload-overlap] def gather(
coro_or_future1: _FutureLike[_T1], coro_or_future1: _FutureLike[_T1],
coro_or_future2: _FutureLike[_T2], coro_or_future2: _FutureLike[_T2],
coro_or_future3: _FutureLike[_T3], coro_or_future3: _FutureLike[_T3],
@ -166,7 +166,7 @@ if sys.version_info >= (3, 10):
return_exceptions: bool, return_exceptions: bool,
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
@overload @overload
def gather( # type: ignore[overload-overlap] def gather(
coro_or_future1: _FutureLike[_T1], coro_or_future1: _FutureLike[_T1],
coro_or_future2: _FutureLike[_T2], coro_or_future2: _FutureLike[_T2],
coro_or_future3: _FutureLike[_T3], coro_or_future3: _FutureLike[_T3],
@ -176,7 +176,7 @@ if sys.version_info >= (3, 10):
return_exceptions: bool, return_exceptions: bool,
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
@overload @overload
def gather( # type: ignore[overload-overlap] def gather(
coro_or_future1: _FutureLike[_T1], coro_or_future1: _FutureLike[_T1],
coro_or_future2: _FutureLike[_T2], coro_or_future2: _FutureLike[_T2],
coro_or_future3: _FutureLike[_T3], coro_or_future3: _FutureLike[_T3],
@ -189,7 +189,7 @@ if sys.version_info >= (3, 10):
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
]: ... ]: ...
@overload @overload
def gather( # type: ignore[overload-overlap] def gather(
coro_or_future1: _FutureLike[_T1], coro_or_future1: _FutureLike[_T1],
coro_or_future2: _FutureLike[_T2], coro_or_future2: _FutureLike[_T2],
coro_or_future3: _FutureLike[_T3], coro_or_future3: _FutureLike[_T3],

View File

@ -159,7 +159,7 @@ if sys.platform != "win32":
class _UnixSelectorEventLoop(BaseSelectorEventLoop): class _UnixSelectorEventLoop(BaseSelectorEventLoop):
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
async def create_unix_server( # type: ignore[override] async def create_unix_server(
self, self,
protocol_factory: _ProtocolFactory, protocol_factory: _ProtocolFactory,
path: StrPath | None = None, path: StrPath | None = None,

View File

@ -1744,7 +1744,7 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
# without creating many false-positive errors (see #7578). # without creating many false-positive errors (see #7578).
# Instead, we special-case the most common examples of this: bool and literal integers. # Instead, we special-case the most common examples of this: bool and literal integers.
@overload @overload
def sum(iterable: Iterable[bool | _LiteralInteger], /, start: int = 0) -> int: ... # type: ignore[overload-overlap] def sum(iterable: Iterable[bool | _LiteralInteger], /, start: int = 0) -> int: ...
@overload @overload
def sum(iterable: Iterable[_SupportsSumNoDefaultT], /) -> _SupportsSumNoDefaultT | Literal[0]: ... def sum(iterable: Iterable[_SupportsSumNoDefaultT], /) -> _SupportsSumNoDefaultT | Literal[0]: ...
@overload @overload
@ -1752,9 +1752,8 @@ def sum(iterable: Iterable[_AddableT1], /, start: _AddableT2) -> _AddableT1 | _A
# The argument to `vars()` has to have a `__dict__` attribute, so the second overload can't be annotated with `object` # The argument to `vars()` has to have a `__dict__` attribute, so the second overload can't be annotated with `object`
# (A "SupportsDunderDict" protocol doesn't work) # (A "SupportsDunderDict" protocol doesn't work)
# Use a type: ignore to make complaints about overlapping overloads go away
@overload @overload
def vars(object: type, /) -> types.MappingProxyType[str, Any]: ... # type: ignore[overload-overlap] def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
@overload @overload
def vars(object: Any = ..., /) -> dict[str, Any]: ... def vars(object: Any = ..., /) -> dict[str, Any]: ...

View File

@ -55,6 +55,7 @@ class AbstractAsyncContextManager(Protocol[_T_co, _ExitT_co]):
) -> _ExitT_co: ... ) -> _ExitT_co: ...
class ContextDecorator: class ContextDecorator:
def _recreate_cm(self) -> Self: ...
def __call__(self, func: _F) -> _F: ... def __call__(self, func: _F) -> _F: ...
class _GeneratorContextManager(AbstractContextManager[_T_co, bool | None], ContextDecorator): class _GeneratorContextManager(AbstractContextManager[_T_co, bool | None], ContextDecorator):
@ -80,6 +81,7 @@ if sys.version_info >= (3, 10):
_AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]]) _AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]])
class AsyncContextDecorator: class AsyncContextDecorator:
def _recreate_cm(self) -> Self: ...
def __call__(self, func: _AF) -> _AF: ... def __call__(self, func: _AF) -> _AF: ...
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co, bool | None], AsyncContextDecorator): class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co, bool | None], AsyncContextDecorator):

View File

@ -1,12 +1,5 @@
import sys import sys
from _ctypes import RTLD_GLOBAL as RTLD_GLOBAL, RTLD_LOCAL as RTLD_LOCAL, Structure, Union from ctypes import Structure, Union
from ctypes import DEFAULT_MODE as DEFAULT_MODE, cdll as cdll, pydll as pydll, pythonapi as pythonapi
if sys.version_info >= (3, 12):
from _ctypes import SIZEOF_TIME_T as SIZEOF_TIME_T
if sys.platform == "win32":
from ctypes import oledll as oledll, windll as windll
# At runtime, the native endianness is an alias for Structure, # At runtime, the native endianness is an alias for Structure,
# while the other is a subclass with a metaclass added in. # while the other is a subclass with a metaclass added in.

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 typing import Any, Generic, Literal, Protocol, TypeVar, overload from typing import Any, Generic, Literal, Protocol, TypeVar, overload
from typing_extensions import TypeAlias, TypeIs from typing_extensions import Never, TypeAlias, TypeIs
if sys.version_info >= (3, 9): if sys.version_info >= (3, 9):
from types import GenericAlias from types import GenericAlias
@ -213,6 +213,10 @@ else:
) -> Any: ... ) -> Any: ...
def fields(class_or_instance: DataclassInstance | type[DataclassInstance]) -> tuple[Field[Any], ...]: ... def fields(class_or_instance: DataclassInstance | type[DataclassInstance]) -> tuple[Field[Any], ...]: ...
# HACK: `obj: Never` typing matches if object argument is using `Any` type.
@overload
def is_dataclass(obj: Never) -> TypeIs[DataclassInstance | type[DataclassInstance]]: ... # type: ignore[narrowed-type-not-subtype] # pyright: ignore[reportGeneralTypeIssues]
@overload @overload
def is_dataclass(obj: type) -> TypeIs[type[DataclassInstance]]: ... def is_dataclass(obj: type) -> TypeIs[type[DataclassInstance]]: ...
@overload @overload

View File

@ -1,6 +1,26 @@
from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused
from abc import abstractmethod from abc import abstractmethod
from collections.abc import Callable, Iterable from collections.abc import Callable, Iterable
from distutils.command.bdist import bdist
from distutils.command.bdist_dumb import bdist_dumb
from distutils.command.bdist_rpm import bdist_rpm
from distutils.command.build import build
from distutils.command.build_clib import build_clib
from distutils.command.build_ext import build_ext
from distutils.command.build_py import build_py
from distutils.command.build_scripts import build_scripts
from distutils.command.check import check
from distutils.command.clean import clean
from distutils.command.config import config
from distutils.command.install import install
from distutils.command.install_data import install_data
from distutils.command.install_egg_info import install_egg_info
from distutils.command.install_headers import install_headers
from distutils.command.install_lib import install_lib
from distutils.command.install_scripts import install_scripts
from distutils.command.register import register
from distutils.command.sdist import sdist
from distutils.command.upload import upload
from distutils.dist import Distribution from distutils.dist import Distribution
from distutils.file_util import _BytesPathT, _StrPathT from distutils.file_util import _BytesPathT, _StrPathT
from typing import Any, ClassVar, Literal, TypeVar, overload from typing import Any, ClassVar, Literal, TypeVar, overload
@ -28,8 +48,108 @@ class Command:
def ensure_dirname(self, option: str) -> None: ... def ensure_dirname(self, option: str) -> None: ...
def get_command_name(self) -> str: ... def get_command_name(self) -> str: ...
def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ... def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ...
# NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst.
@overload
def get_finalized_command(self, command: Literal["bdist"], create: bool | Literal[0, 1] = 1) -> bdist: ...
@overload
def get_finalized_command(self, command: Literal["bdist_dumb"], create: bool | Literal[0, 1] = 1) -> bdist_dumb: ...
@overload
def get_finalized_command(self, command: Literal["bdist_rpm"], create: bool | Literal[0, 1] = 1) -> bdist_rpm: ...
@overload
def get_finalized_command(self, command: Literal["build"], create: bool | Literal[0, 1] = 1) -> build: ...
@overload
def get_finalized_command(self, command: Literal["build_clib"], create: bool | Literal[0, 1] = 1) -> build_clib: ...
@overload
def get_finalized_command(self, command: Literal["build_ext"], create: bool | Literal[0, 1] = 1) -> build_ext: ...
@overload
def get_finalized_command(self, command: Literal["build_py"], create: bool | Literal[0, 1] = 1) -> build_py: ...
@overload
def get_finalized_command(self, command: Literal["build_scripts"], create: bool | Literal[0, 1] = 1) -> build_scripts: ...
@overload
def get_finalized_command(self, command: Literal["check"], create: bool | Literal[0, 1] = 1) -> check: ...
@overload
def get_finalized_command(self, command: Literal["clean"], create: bool | Literal[0, 1] = 1) -> clean: ...
@overload
def get_finalized_command(self, command: Literal["config"], create: bool | Literal[0, 1] = 1) -> config: ...
@overload
def get_finalized_command(self, command: Literal["install"], create: bool | Literal[0, 1] = 1) -> install: ...
@overload
def get_finalized_command(self, command: Literal["install_data"], create: bool | Literal[0, 1] = 1) -> install_data: ...
@overload
def get_finalized_command(
self, command: Literal["install_egg_info"], create: bool | Literal[0, 1] = 1
) -> install_egg_info: ...
@overload
def get_finalized_command(self, command: Literal["install_headers"], create: bool | Literal[0, 1] = 1) -> install_headers: ...
@overload
def get_finalized_command(self, command: Literal["install_lib"], create: bool | Literal[0, 1] = 1) -> install_lib: ...
@overload
def get_finalized_command(self, command: Literal["install_scripts"], create: bool | Literal[0, 1] = 1) -> install_scripts: ...
@overload
def get_finalized_command(self, command: Literal["register"], create: bool | Literal[0, 1] = 1) -> register: ...
@overload
def get_finalized_command(self, command: Literal["sdist"], create: bool | Literal[0, 1] = 1) -> sdist: ...
@overload
def get_finalized_command(self, command: Literal["upload"], create: bool | Literal[0, 1] = 1) -> upload: ...
@overload
def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ... def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ...
@overload @overload
def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool | Literal[0, 1] = 0) -> bdist: ...
@overload
def reinitialize_command(
self, command: Literal["bdist_dumb"], reinit_subcommands: bool | Literal[0, 1] = 0
) -> bdist_dumb: ...
@overload
def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool | Literal[0, 1] = 0) -> bdist_rpm: ...
@overload
def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build: ...
@overload
def reinitialize_command(
self, command: Literal["build_clib"], reinit_subcommands: bool | Literal[0, 1] = 0
) -> build_clib: ...
@overload
def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build_ext: ...
@overload
def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build_py: ...
@overload
def reinitialize_command(
self, command: Literal["build_scripts"], reinit_subcommands: bool | Literal[0, 1] = 0
) -> build_scripts: ...
@overload
def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool | Literal[0, 1] = 0) -> check: ...
@overload
def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool | Literal[0, 1] = 0) -> clean: ...
@overload
def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool | Literal[0, 1] = 0) -> config: ...
@overload
def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool | Literal[0, 1] = 0) -> install: ...
@overload
def reinitialize_command(
self, command: Literal["install_data"], reinit_subcommands: bool | Literal[0, 1] = 0
) -> install_data: ...
@overload
def reinitialize_command(
self, command: Literal["install_egg_info"], reinit_subcommands: bool | Literal[0, 1] = 0
) -> install_egg_info: ...
@overload
def reinitialize_command(
self, command: Literal["install_headers"], reinit_subcommands: bool | Literal[0, 1] = 0
) -> install_headers: ...
@overload
def reinitialize_command(
self, command: Literal["install_lib"], reinit_subcommands: bool | Literal[0, 1] = 0
) -> install_lib: ...
@overload
def reinitialize_command(
self, command: Literal["install_scripts"], reinit_subcommands: bool | Literal[0, 1] = 0
) -> install_scripts: ...
@overload
def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool | Literal[0, 1] = 0) -> register: ...
@overload
def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool | Literal[0, 1] = 0) -> sdist: ...
@overload
def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool | Literal[0, 1] = 0) -> upload: ...
@overload
def reinitialize_command(self, command: str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ... def reinitialize_command(self, command: str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ...
@overload @overload
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool | Literal[0, 1] = 0) -> _CommandT: ... def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool | Literal[0, 1] = 0) -> _CommandT: ...

View File

@ -0,0 +1,48 @@
import sys
from . import (
bdist,
bdist_dumb,
bdist_rpm,
build,
build_clib,
build_ext,
build_py,
build_scripts,
check,
clean,
install,
install_data,
install_headers,
install_lib,
install_scripts,
register,
sdist,
upload,
)
__all__ = [
"build",
"build_py",
"build_ext",
"build_clib",
"build_scripts",
"clean",
"install",
"install_lib",
"install_headers",
"install_scripts",
"install_data",
"sdist",
"register",
"bdist",
"bdist_dumb",
"bdist_rpm",
"check",
"upload",
]
if sys.version_info < (3, 10):
from . import bdist_wininst
__all__ += ["bdist_wininst"]

View File

@ -1,6 +1,26 @@
from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite
from collections.abc import Iterable, MutableMapping from collections.abc import Iterable, MutableMapping
from distutils.cmd import Command from distutils.cmd import Command
from distutils.command.bdist import bdist
from distutils.command.bdist_dumb import bdist_dumb
from distutils.command.bdist_rpm import bdist_rpm
from distutils.command.build import build
from distutils.command.build_clib import build_clib
from distutils.command.build_ext import build_ext
from distutils.command.build_py import build_py
from distutils.command.build_scripts import build_scripts
from distutils.command.check import check
from distutils.command.clean import clean
from distutils.command.config import config
from distutils.command.install import install
from distutils.command.install_data import install_data
from distutils.command.install_egg_info import install_egg_info
from distutils.command.install_headers import install_headers
from distutils.command.install_lib import install_lib
from distutils.command.install_scripts import install_scripts
from distutils.command.register import register
from distutils.command.sdist import sdist
from distutils.command.upload import upload
from re import Pattern from re import Pattern
from typing import IO, ClassVar, Literal, TypeVar, overload from typing import IO, ClassVar, Literal, TypeVar, overload
from typing_extensions import TypeAlias from typing_extensions import TypeAlias
@ -63,10 +83,6 @@ class Distribution:
def __init__(self, attrs: MutableMapping[str, Incomplete] | None = None) -> None: ... def __init__(self, attrs: MutableMapping[str, Incomplete] | None = None) -> None: ...
def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ... def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ...
def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ... def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ...
@overload
def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ...
@overload
def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ...
global_options: ClassVar[_OptionsList] global_options: ClassVar[_OptionsList]
common_usage: ClassVar[str] common_usage: ClassVar[str]
display_options: ClassVar[_OptionsList] display_options: ClassVar[_OptionsList]
@ -108,8 +124,137 @@ class Distribution:
def print_commands(self) -> None: ... def print_commands(self) -> None: ...
def get_command_list(self): ... def get_command_list(self): ...
def get_command_packages(self): ... def get_command_packages(self): ...
# NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst.
@overload
def get_command_obj(self, command: Literal["bdist"], create: Literal[1, True] = 1) -> bdist: ...
@overload
def get_command_obj(self, command: Literal["bdist_dumb"], create: Literal[1, True] = 1) -> bdist_dumb: ...
@overload
def get_command_obj(self, command: Literal["bdist_rpm"], create: Literal[1, True] = 1) -> bdist_rpm: ...
@overload
def get_command_obj(self, command: Literal["build"], create: Literal[1, True] = 1) -> build: ...
@overload
def get_command_obj(self, command: Literal["build_clib"], create: Literal[1, True] = 1) -> build_clib: ...
@overload
def get_command_obj(self, command: Literal["build_ext"], create: Literal[1, True] = 1) -> build_ext: ...
@overload
def get_command_obj(self, command: Literal["build_py"], create: Literal[1, True] = 1) -> build_py: ...
@overload
def get_command_obj(self, command: Literal["build_scripts"], create: Literal[1, True] = 1) -> build_scripts: ...
@overload
def get_command_obj(self, command: Literal["check"], create: Literal[1, True] = 1) -> check: ...
@overload
def get_command_obj(self, command: Literal["clean"], create: Literal[1, True] = 1) -> clean: ...
@overload
def get_command_obj(self, command: Literal["config"], create: Literal[1, True] = 1) -> config: ...
@overload
def get_command_obj(self, command: Literal["install"], create: Literal[1, True] = 1) -> install: ...
@overload
def get_command_obj(self, command: Literal["install_data"], create: Literal[1, True] = 1) -> install_data: ...
@overload
def get_command_obj(self, command: Literal["install_egg_info"], create: Literal[1, True] = 1) -> install_egg_info: ...
@overload
def get_command_obj(self, command: Literal["install_headers"], create: Literal[1, True] = 1) -> install_headers: ...
@overload
def get_command_obj(self, command: Literal["install_lib"], create: Literal[1, True] = 1) -> install_lib: ...
@overload
def get_command_obj(self, command: Literal["install_scripts"], create: Literal[1, True] = 1) -> install_scripts: ...
@overload
def get_command_obj(self, command: Literal["register"], create: Literal[1, True] = 1) -> register: ...
@overload
def get_command_obj(self, command: Literal["sdist"], create: Literal[1, True] = 1) -> sdist: ...
@overload
def get_command_obj(self, command: Literal["upload"], create: Literal[1, True] = 1) -> upload: ...
@overload
def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ...
# Not replicating the overloads for "Command | None", user may use "isinstance"
@overload
def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ...
@overload
def get_command_class(self, command: Literal["bdist"]) -> type[bdist]: ...
@overload
def get_command_class(self, command: Literal["bdist_dumb"]) -> type[bdist_dumb]: ...
@overload
def get_command_class(self, command: Literal["bdist_rpm"]) -> type[bdist_rpm]: ...
@overload
def get_command_class(self, command: Literal["build"]) -> type[build]: ...
@overload
def get_command_class(self, command: Literal["build_clib"]) -> type[build_clib]: ...
@overload
def get_command_class(self, command: Literal["build_ext"]) -> type[build_ext]: ...
@overload
def get_command_class(self, command: Literal["build_py"]) -> type[build_py]: ...
@overload
def get_command_class(self, command: Literal["build_scripts"]) -> type[build_scripts]: ...
@overload
def get_command_class(self, command: Literal["check"]) -> type[check]: ...
@overload
def get_command_class(self, command: Literal["clean"]) -> type[clean]: ...
@overload
def get_command_class(self, command: Literal["config"]) -> type[config]: ...
@overload
def get_command_class(self, command: Literal["install"]) -> type[install]: ...
@overload
def get_command_class(self, command: Literal["install_data"]) -> type[install_data]: ...
@overload
def get_command_class(self, command: Literal["install_egg_info"]) -> type[install_egg_info]: ...
@overload
def get_command_class(self, command: Literal["install_headers"]) -> type[install_headers]: ...
@overload
def get_command_class(self, command: Literal["install_lib"]) -> type[install_lib]: ...
@overload
def get_command_class(self, command: Literal["install_scripts"]) -> type[install_scripts]: ...
@overload
def get_command_class(self, command: Literal["register"]) -> type[register]: ...
@overload
def get_command_class(self, command: Literal["sdist"]) -> type[sdist]: ...
@overload
def get_command_class(self, command: Literal["upload"]) -> type[upload]: ...
@overload
def get_command_class(self, command: str) -> type[Command]: ... def get_command_class(self, command: str) -> type[Command]: ...
@overload @overload
def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool = False) -> bdist: ...
@overload
def reinitialize_command(self, command: Literal["bdist_dumb"], reinit_subcommands: bool = False) -> bdist_dumb: ...
@overload
def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False) -> bdist_rpm: ...
@overload
def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool = False) -> build: ...
@overload
def reinitialize_command(self, command: Literal["build_clib"], reinit_subcommands: bool = False) -> build_clib: ...
@overload
def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool = False) -> build_ext: ...
@overload
def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool = False) -> build_py: ...
@overload
def reinitialize_command(self, command: Literal["build_scripts"], reinit_subcommands: bool = False) -> build_scripts: ...
@overload
def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool = False) -> check: ...
@overload
def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool = False) -> clean: ...
@overload
def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool = False) -> config: ...
@overload
def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool = False) -> install: ...
@overload
def reinitialize_command(self, command: Literal["install_data"], reinit_subcommands: bool = False) -> install_data: ...
@overload
def reinitialize_command(
self, command: Literal["install_egg_info"], reinit_subcommands: bool = False
) -> install_egg_info: ...
@overload
def reinitialize_command(self, command: Literal["install_headers"], reinit_subcommands: bool = False) -> install_headers: ...
@overload
def reinitialize_command(self, command: Literal["install_lib"], reinit_subcommands: bool = False) -> install_lib: ...
@overload
def reinitialize_command(self, command: Literal["install_scripts"], reinit_subcommands: bool = False) -> install_scripts: ...
@overload
def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool = False) -> register: ...
@overload
def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool = False) -> sdist: ...
@overload
def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool = False) -> upload: ...
@overload
def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ...
@overload @overload
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ... def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ...

View File

@ -66,7 +66,10 @@ def mktime_tz(data: _PDTZ) -> int: ...
def formatdate(timeval: float | None = None, localtime: bool = False, usegmt: bool = False) -> str: ... def formatdate(timeval: float | None = None, localtime: bool = False, usegmt: bool = False) -> str: ...
def format_datetime(dt: datetime.datetime, usegmt: bool = False) -> str: ... def format_datetime(dt: datetime.datetime, usegmt: bool = False) -> str: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 14):
def localtime(dt: datetime.datetime | None = None) -> datetime.datetime: ...
elif sys.version_info >= (3, 12):
@overload @overload
def localtime(dt: datetime.datetime | None = None) -> datetime.datetime: ... def localtime(dt: datetime.datetime | None = None) -> datetime.datetime: ...
@overload @overload

View File

@ -17,13 +17,24 @@ def cmpfiles(
) -> tuple[list[AnyStr], list[AnyStr], list[AnyStr]]: ... ) -> tuple[list[AnyStr], list[AnyStr], list[AnyStr]]: ...
class dircmp(Generic[AnyStr]): class dircmp(Generic[AnyStr]):
def __init__( if sys.version_info >= (3, 13):
self, def __init__(
a: GenericPath[AnyStr], self,
b: GenericPath[AnyStr], a: GenericPath[AnyStr],
ignore: Sequence[AnyStr] | None = None, b: GenericPath[AnyStr],
hide: Sequence[AnyStr] | None = None, ignore: Sequence[AnyStr] | None = None,
) -> None: ... hide: Sequence[AnyStr] | None = None,
*,
shallow: bool = True,
) -> None: ...
else:
def __init__(
self,
a: GenericPath[AnyStr],
b: GenericPath[AnyStr],
ignore: Sequence[AnyStr] | None = None,
hide: Sequence[AnyStr] | None = None,
) -> None: ...
left: AnyStr left: AnyStr
right: AnyStr right: AnyStr
hide: Sequence[AnyStr] hide: Sequence[AnyStr]

View File

@ -155,7 +155,7 @@ if sys.version_info >= (3, 10) and sys.version_info < (3, 12):
@property @property
def names(self) -> set[str]: ... def names(self) -> set[str]: ...
@overload @overload
def select(self) -> Self: ... # type: ignore[misc] def select(self) -> Self: ...
@overload @overload
def select( def select(
self, self,
@ -277,7 +277,7 @@ if sys.version_info >= (3, 12):
elif sys.version_info >= (3, 10): elif sys.version_info >= (3, 10):
@overload @overload
def entry_points() -> SelectableGroups: ... # type: ignore[overload-overlap] def entry_points() -> SelectableGroups: ...
@overload @overload
def entry_points( def entry_points(
*, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ... *, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ...

View File

@ -6,7 +6,7 @@ from ..pytree import Node
class FixUnicode(fixer_base.BaseFix): class FixUnicode(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]] BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[Literal["STRING | 'unicode' | 'unichr'"]] # type: ignore[name-defined] # Name "STRING" is not defined PATTERN: ClassVar[str]
unicode_literals: bool unicode_literals: bool
def start_tree(self, tree: Node, filename: StrPath) -> None: ... def start_tree(self, tree: Node, filename: StrPath) -> None: ...
def transform(self, node, results): ... def transform(self, node, results): ...

View File

@ -55,10 +55,9 @@ __all__ = [
"setLogRecordFactory", "setLogRecordFactory",
"lastResort", "lastResort",
"raiseExceptions", "raiseExceptions",
"warn",
] ]
if sys.version_info < (3, 13):
__all__ += ["warn"]
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
__all__ += ["getLevelNamesMapping"] __all__ += ["getLevelNamesMapping"]
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
@ -157,17 +156,16 @@ class Logger(Filterer):
stacklevel: int = 1, stacklevel: int = 1,
extra: Mapping[str, object] | None = None, extra: Mapping[str, object] | None = None,
) -> None: ... ) -> None: ...
if sys.version_info < (3, 13): @deprecated("Deprecated; use warning() instead.")
def warn( def warn(
self, self,
msg: object, msg: object,
*args: object, *args: object,
exc_info: _ExcInfoType = None, exc_info: _ExcInfoType = None,
stack_info: bool = False, stack_info: bool = False,
stacklevel: int = 1, stacklevel: int = 1,
extra: Mapping[str, object] | None = None, extra: Mapping[str, object] | None = None,
) -> None: ... ) -> None: ...
def error( def error(
self, self,
msg: object, msg: object,
@ -412,18 +410,17 @@ class LoggerAdapter(Generic[_L]):
extra: Mapping[str, object] | None = None, extra: Mapping[str, object] | None = None,
**kwargs: object, **kwargs: object,
) -> None: ... ) -> None: ...
if sys.version_info < (3, 13): @deprecated("Deprecated; use warning() instead.")
def warn( def warn(
self, self,
msg: object, msg: object,
*args: object, *args: object,
exc_info: _ExcInfoType = None, exc_info: _ExcInfoType = None,
stack_info: bool = False, stack_info: bool = False,
stacklevel: int = 1, stacklevel: int = 1,
extra: Mapping[str, object] | None = None, extra: Mapping[str, object] | None = None,
**kwargs: object, **kwargs: object,
) -> None: ... ) -> None: ...
def error( def error(
self, self,
msg: object, msg: object,
@ -523,17 +520,15 @@ def warning(
stacklevel: int = 1, stacklevel: int = 1,
extra: Mapping[str, object] | None = None, extra: Mapping[str, object] | None = None,
) -> None: ... ) -> None: ...
@deprecated("Deprecated; use warning() instead.")
if sys.version_info < (3, 13): def warn(
def warn( msg: object,
msg: object, *args: object,
*args: object, exc_info: _ExcInfoType = None,
exc_info: _ExcInfoType = None, stack_info: bool = False,
stack_info: bool = False, stacklevel: int = 1,
stacklevel: int = 1, extra: Mapping[str, object] | None = None,
extra: Mapping[str, object] | None = None, ) -> None: ...
) -> None: ...
def error( def error(
msg: object, msg: object,
*args: object, *args: object,

View File

@ -73,7 +73,7 @@ def copy(obj: _CT) -> _CT: ...
@overload @overload
def synchronized(obj: _SimpleCData[_T], lock: _LockLike | None = None, ctx: Any | None = None) -> Synchronized[_T]: ... def synchronized(obj: _SimpleCData[_T], lock: _LockLike | None = None, ctx: Any | None = None) -> Synchronized[_T]: ...
@overload @overload
def synchronized(obj: ctypes.Array[c_char], lock: _LockLike | None = None, ctx: Any | None = None) -> SynchronizedString: ... # type: ignore def synchronized(obj: ctypes.Array[c_char], lock: _LockLike | None = None, ctx: Any | None = None) -> SynchronizedString: ...
@overload @overload
def synchronized( def synchronized(
obj: ctypes.Array[_SimpleCData[_T]], lock: _LockLike | None = None, ctx: Any | None = None obj: ctypes.Array[_SimpleCData[_T]], lock: _LockLike | None = None, ctx: Any | None = None
@ -115,12 +115,12 @@ class SynchronizedArray(SynchronizedBase[ctypes.Array[_SimpleCData[_T]]], Generi
class SynchronizedString(SynchronizedArray[bytes]): class SynchronizedString(SynchronizedArray[bytes]):
@overload # type: ignore[override] @overload # type: ignore[override]
def __getitem__(self, i: slice) -> bytes: ... def __getitem__(self, i: slice) -> bytes: ...
@overload # type: ignore[override] @overload
def __getitem__(self, i: int) -> bytes: ... def __getitem__(self, i: int) -> bytes: ...
@overload # type: ignore[override] @overload # type: ignore[override]
def __setitem__(self, i: slice, value: bytes) -> None: ... def __setitem__(self, i: slice, value: bytes) -> None: ...
@overload # type: ignore[override] @overload
def __setitem__(self, i: int, value: bytes) -> None: ... # type: ignore[override] def __setitem__(self, i: int, value: bytes) -> None: ...
def __getslice__(self, start: int, stop: int) -> bytes: ... # type: ignore[override] def __getslice__(self, start: int, stop: int) -> bytes: ... # type: ignore[override]
def __setslice__(self, start: int, stop: int, values: bytes) -> None: ... # type: ignore[override] def __setslice__(self, start: int, stop: int, values: bytes) -> None: ... # type: ignore[override]

View File

@ -159,6 +159,20 @@ class Path(PurePath):
def lchmod(self, mode: int) -> None: ... def lchmod(self, mode: int) -> None: ...
def lstat(self) -> stat_result: ... def lstat(self) -> stat_result: ...
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):
def copy(self, target: StrPath, *, follow_symlinks: bool = True, preserve_metadata: bool = False) -> None: ...
def copytree(
self,
target: StrPath,
*,
follow_symlinks: bool = True,
preserve_metadata: bool = False,
dirs_exist_ok: bool = False,
ignore: Callable[[Self], bool] | None = None,
on_error: Callable[[OSError], object] | None = None,
) -> None: ...
# Adapted from builtins.open # Adapted from builtins.open
# Text mode: always returns a TextIOWrapper # Text mode: always returns a TextIOWrapper
# The Traversable .open in stdlib/importlib/abc.pyi should be kept in sync with this. # The Traversable .open in stdlib/importlib/abc.pyi should be kept in sync with this.
@ -232,10 +246,18 @@ class Path(PurePath):
if sys.version_info >= (3, 9): if sys.version_info >= (3, 9):
def readlink(self) -> Self: ... def readlink(self) -> Self: ...
def rename(self, target: str | PurePath) -> Self: ... if sys.version_info >= (3, 10):
def replace(self, target: str | PurePath) -> Self: ... def rename(self, target: StrPath) -> Self: ...
def replace(self, target: StrPath) -> Self: ...
else:
def rename(self, target: str | PurePath) -> Self: ...
def replace(self, target: str | PurePath) -> Self: ...
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: ...
@ -266,6 +288,9 @@ 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

@ -84,7 +84,7 @@ class Pdb(Bdb, Cmd):
def _runscript(self, filename: str) -> None: ... def _runscript(self, filename: str) -> None: ...
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]: ... # type: ignore[override] def completedefault(self, text: str, line: str, begidx: int, endidx: int) -> list[str]: ...
def do_commands(self, arg: str) -> bool | None: ... def do_commands(self, arg: str) -> bool | None: ...
def do_break(self, arg: str, temporary: bool = ...) -> bool | None: ... def do_break(self, arg: str, temporary: bool = ...) -> bool | None: ...

View File

@ -1,7 +1,7 @@
import sys import sys
from collections.abc import Callable, Iterable from collections.abc import Callable, Iterable
from typing import Final from typing import Final
from typing_extensions import TypeAlias from typing_extensions import TypeAlias, deprecated
if sys.platform != "win32": if sys.platform != "win32":
__all__ = ["openpty", "fork", "spawn"] __all__ = ["openpty", "fork", "spawn"]
@ -13,7 +13,12 @@ if sys.platform != "win32":
CHILD: Final = 0 CHILD: Final = 0
def openpty() -> tuple[int, int]: ... def openpty() -> tuple[int, int]: ...
def master_open() -> tuple[int, str]: ... # deprecated, use openpty()
def slave_open(tty_name: str) -> int: ... # deprecated, use openpty() if sys.version_info < (3, 14):
@deprecated("Deprecated in 3.12, to be removed in 3.14; use openpty() instead")
def master_open() -> tuple[int, str]: ...
@deprecated("Deprecated in 3.12, to be removed in 3.14; use openpty() instead")
def slave_open(tty_name: str) -> int: ...
def fork() -> tuple[int, int]: ... def fork() -> tuple[int, int]: ...
def spawn(argv: str | Iterable[str], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ... def spawn(argv: str | Iterable[str], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ...

View File

@ -74,7 +74,7 @@ class Match(Generic[AnyStr]):
@overload @overload
def expand(self: Match[str], template: str) -> str: ... def expand(self: Match[str], template: str) -> str: ...
@overload @overload
def expand(self: Match[bytes], template: ReadableBuffer) -> bytes: ... # type: ignore[overload-overlap] def expand(self: Match[bytes], template: ReadableBuffer) -> bytes: ...
@overload @overload
def expand(self, template: AnyStr) -> AnyStr: ... def expand(self, template: AnyStr) -> AnyStr: ...
# group() returns "AnyStr" or "AnyStr | None", depending on the pattern. # group() returns "AnyStr" or "AnyStr | None", depending on the pattern.
@ -124,19 +124,21 @@ class Pattern(Generic[AnyStr]):
@overload @overload
def search(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Match[str] | None: ... def search(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Match[str] | None: ...
@overload @overload
def search(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Match[bytes] | None: ... # type: ignore[overload-overlap] def search(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Match[bytes] | None: ...
@overload @overload
def search(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Match[AnyStr] | None: ... def search(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Match[AnyStr] | None: ...
@overload @overload
def match(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Match[str] | None: ... def match(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Match[str] | None: ...
@overload @overload
def match(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Match[bytes] | None: ... # type: ignore[overload-overlap] def match(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Match[bytes] | None: ...
@overload @overload
def match(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Match[AnyStr] | None: ... def match(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Match[AnyStr] | None: ...
@overload @overload
def fullmatch(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Match[str] | None: ... def fullmatch(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Match[str] | None: ...
@overload @overload
def fullmatch(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Match[bytes] | None: ... # type: ignore[overload-overlap] def fullmatch(
self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize
) -> Match[bytes] | None: ...
@overload @overload
def fullmatch(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Match[AnyStr] | None: ... def fullmatch(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Match[AnyStr] | None: ...
@overload @overload
@ -155,13 +157,15 @@ class Pattern(Generic[AnyStr]):
@overload @overload
def finditer(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Iterator[Match[str]]: ... def finditer(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Iterator[Match[str]]: ...
@overload @overload
def finditer(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Iterator[Match[bytes]]: ... # type: ignore[overload-overlap] def finditer(
self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize
) -> Iterator[Match[bytes]]: ...
@overload @overload
def finditer(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Iterator[Match[AnyStr]]: ... def finditer(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Iterator[Match[AnyStr]]: ...
@overload @overload
def sub(self: Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = 0) -> str: ... def sub(self: Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = 0) -> str: ...
@overload @overload
def sub( # type: ignore[overload-overlap] def sub(
self: Pattern[bytes], self: Pattern[bytes],
repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer],
string: ReadableBuffer, string: ReadableBuffer,
@ -172,7 +176,7 @@ class Pattern(Generic[AnyStr]):
@overload @overload
def subn(self: Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = 0) -> tuple[str, int]: ... def subn(self: Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = 0) -> tuple[str, int]: ...
@overload @overload
def subn( # type: ignore[overload-overlap] def subn(
self: Pattern[bytes], self: Pattern[bytes],
repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer],
string: ReadableBuffer, string: ReadableBuffer,

View File

@ -29,7 +29,10 @@ def DateFromTicks(ticks: float) -> Date: ...
def TimeFromTicks(ticks: float) -> Time: ... def TimeFromTicks(ticks: float) -> Time: ...
def TimestampFromTicks(ticks: float) -> Timestamp: ... def TimestampFromTicks(ticks: float) -> Timestamp: ...
version_info: tuple[int, int, int] if sys.version_info < (3, 14):
# Deprecated in 3.12, removed in 3.14.
version_info: tuple[int, int, int]
sqlite_version_info: tuple[int, int, int] sqlite_version_info: tuple[int, int, int]
Binary = memoryview Binary = memoryview
@ -90,7 +93,10 @@ SQLITE_UPDATE: Final[int]
adapters: dict[tuple[type[Any], type[Any]], _Adapter[Any]] adapters: dict[tuple[type[Any], type[Any]], _Adapter[Any]]
converters: dict[str, _Converter] converters: dict[str, _Converter]
sqlite_version: str sqlite_version: str
version: str
if sys.version_info < (3, 14):
# Deprecated in 3.12, removed in 3.14.
version: str
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
SQLITE_ABORT: Final[int] SQLITE_ABORT: Final[int]

View File

@ -2,6 +2,7 @@ import sys
from _collections_abc import dict_keys from _collections_abc import dict_keys
from collections.abc import Sequence from collections.abc import Sequence
from typing import Any from typing import Any
from typing_extensions import deprecated
__all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"] __all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"]
@ -51,7 +52,9 @@ class Function(SymbolTable):
def get_nonlocals(self) -> tuple[str, ...]: ... def get_nonlocals(self) -> tuple[str, ...]: ...
class Class(SymbolTable): class Class(SymbolTable):
def get_methods(self) -> tuple[str, ...]: ... if sys.version_info < (3, 16):
@deprecated("deprecated in Python 3.14, will be removed in Python 3.16")
def get_methods(self) -> tuple[str, ...]: ...
class Symbol: class Symbol:
def __init__( def __init__(

View File

@ -423,7 +423,7 @@ class TarInfo:
name: str name: str
path: str path: str
size: int size: int
mtime: int mtime: int | float
chksum: int chksum: int
devmajor: int devmajor: int
devminor: int devminor: int

View File

@ -463,7 +463,7 @@ class TemporaryDirectory(Generic[AnyStr]):
# The overloads overlap, but they should still work fine. # The overloads overlap, but they should still work fine.
@overload @overload
def mkstemp( # type: ignore[overload-overlap] def mkstemp(
suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None, text: bool = False suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None, text: bool = False
) -> tuple[int, str]: ... ) -> tuple[int, str]: ...
@overload @overload
@ -473,7 +473,7 @@ def mkstemp(
# The overloads overlap, but they should still work fine. # The overloads overlap, but they should still work fine.
@overload @overload
def mkdtemp(suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None) -> str: ... # type: ignore[overload-overlap] def mkdtemp(suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None) -> str: ...
@overload @overload
def mkdtemp(suffix: bytes | None = None, prefix: bytes | None = None, dir: BytesPath | None = None) -> bytes: ... def mkdtemp(suffix: bytes | None = None, prefix: bytes | None = None, dir: BytesPath | None = None) -> bytes: ...
def mktemp(suffix: str = "", prefix: str = "tmp", dir: StrPath | None = None) -> str: ... def mktemp(suffix: str = "", prefix: str = "tmp", dir: StrPath | None = None) -> str: ...

View File

@ -2148,11 +2148,12 @@ class Listbox(Widget, XView, YView):
selectborderwidth: _ScreenUnits = 0, selectborderwidth: _ScreenUnits = 0,
selectforeground: str = ..., selectforeground: str = ...,
# from listbox man page: "The value of the [selectmode] option may be # from listbox man page: "The value of the [selectmode] option may be
# arbitrary, but the default bindings expect it to be ..." # arbitrary, but the default bindings expect it to be either single,
# browse, multiple, or extended"
# #
# I have never seen anyone setting this to something else than what # I have never seen anyone setting this to something else than what
# "the default bindings expect", but let's support it anyway. # "the default bindings expect", but let's support it anyway.
selectmode: str = "browse", selectmode: str | Literal["single", "browse", "multiple", "extended"] = "browse", # noqa: Y051
setgrid: bool = False, setgrid: bool = False,
state: Literal["normal", "disabled"] = "normal", state: Literal["normal", "disabled"] = "normal",
takefocus: _TakeFocusValue = "", takefocus: _TakeFocusValue = "",
@ -2187,7 +2188,7 @@ class Listbox(Widget, XView, YView):
selectbackground: str = ..., selectbackground: str = ...,
selectborderwidth: _ScreenUnits = ..., selectborderwidth: _ScreenUnits = ...,
selectforeground: str = ..., selectforeground: str = ...,
selectmode: str = ..., selectmode: str | Literal["single", "browse", "multiple", "extended"] = ..., # noqa: Y051
setgrid: bool = ..., setgrid: bool = ...,
state: Literal["normal", "disabled"] = ..., state: Literal["normal", "disabled"] = ...,
takefocus: _TakeFocusValue = ..., takefocus: _TakeFocusValue = ...,
@ -2907,6 +2908,9 @@ class Scrollbar(Widget):
def set(self, first: float | str, last: float | str) -> None: ... def set(self, first: float | str, last: float | str) -> None: ...
_TextIndex: TypeAlias = _tkinter.Tcl_Obj | str | float | Misc _TextIndex: TypeAlias = _tkinter.Tcl_Obj | str | float | Misc
_WhatToCount: TypeAlias = Literal[
"chars", "displaychars", "displayindices", "displaylines", "indices", "lines", "xpixels", "ypixels"
]
class Text(Widget, XView, YView): class Text(Widget, XView, YView):
def __init__( def __init__(
@ -3021,7 +3025,27 @@ class Text(Widget, XView, YView):
config = configure config = configure
def bbox(self, index: _TextIndex) -> tuple[int, int, int, int] | None: ... # type: ignore[override] def bbox(self, index: _TextIndex) -> tuple[int, int, int, int] | None: ... # type: ignore[override]
def compare(self, index1: _TextIndex, op: Literal["<", "<=", "==", ">=", ">", "!="], index2: _TextIndex) -> bool: ... def compare(self, index1: _TextIndex, op: Literal["<", "<=", "==", ">=", ">", "!="], index2: _TextIndex) -> bool: ...
def count(self, index1, index2, *args): ... # TODO @overload
def count(self, index1: _TextIndex, index2: _TextIndex) -> tuple[int] | None: ...
@overload
def count(self, index1: _TextIndex, index2: _TextIndex, arg: _WhatToCount | Literal["update"], /) -> tuple[int] | None: ...
@overload
def count(self, index1: _TextIndex, index2: _TextIndex, arg1: Literal["update"], arg2: _WhatToCount, /) -> int | None: ...
@overload
def count(self, index1: _TextIndex, index2: _TextIndex, arg1: _WhatToCount, arg2: Literal["update"], /) -> int | None: ...
@overload
def count(self, index1: _TextIndex, index2: _TextIndex, arg1: _WhatToCount, arg2: _WhatToCount, /) -> tuple[int, int]: ...
@overload
def count(
self,
index1: _TextIndex,
index2: _TextIndex,
arg1: _WhatToCount | Literal["update"],
arg2: _WhatToCount | Literal["update"],
arg3: _WhatToCount | Literal["update"],
/,
*args: _WhatToCount | Literal["update"],
) -> tuple[int, ...]: ...
@overload @overload
def debug(self, boolean: None = None) -> bool: ... def debug(self, boolean: None = None) -> bool: ...
@overload @overload
@ -3564,7 +3588,7 @@ class Spinbox(Widget, XView):
def scan_dragto(self, x): ... def scan_dragto(self, x): ...
def selection(self, *args) -> tuple[int, ...]: ... def selection(self, *args) -> tuple[int, ...]: ...
def selection_adjust(self, index): ... def selection_adjust(self, index): ...
def selection_clear(self): ... def selection_clear(self): ... # type: ignore[override]
def selection_element(self, element: Incomplete | None = None): ... def selection_element(self, element: Incomplete | None = None): ...
def selection_from(self, index: int) -> None: ... def selection_from(self, index: int) -> None: ...
def selection_present(self) -> None: ... def selection_present(self) -> None: ...

View File

@ -1040,7 +1040,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
@overload @overload
def heading(self, column: str | int, option: str) -> Any: ... def heading(self, column: str | int, option: str) -> Any: ...
@overload @overload
def heading(self, column: str | int, option: None = None) -> _TreeviewHeaderDict: ... # type: ignore[overload-overlap] def heading(self, column: str | int, option: None = None) -> _TreeviewHeaderDict: ...
@overload @overload
def heading( def heading(
self, self,
@ -1052,7 +1052,8 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
anchor: tkinter._Anchor = ..., anchor: tkinter._Anchor = ...,
command: str | Callable[[], object] = ..., command: str | Callable[[], object] = ...,
) -> None: ... ) -> None: ...
def identify(self, component, x, y): ... # Internal Method. Leave untyped # Internal Method. Leave untyped:
def identify(self, component, x, y): ... # type: ignore[override]
def identify_row(self, y: int) -> str: ... def identify_row(self, y: int) -> str: ...
def identify_column(self, x: int) -> str: ... def identify_column(self, x: int) -> str: ...
def identify_region(self, x: int, y: int) -> Literal["heading", "separator", "tree", "cell", "nothing"]: ... def identify_region(self, x: int, y: int) -> Literal["heading", "separator", "tree", "cell", "nothing"]: ...
@ -1084,7 +1085,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
@overload @overload
def item(self, item: str | int, option: str) -> Any: ... def item(self, item: str | int, option: str) -> Any: ...
@overload @overload
def item(self, item: str | int, option: None = None) -> _TreeviewItemDict: ... # type: ignore[overload-overlap] def item(self, item: str | int, option: None = None) -> _TreeviewItemDict: ...
@overload @overload
def item( def item(
self, self,

View File

@ -338,7 +338,7 @@ class TPen:
def isvisible(self) -> bool: ... def isvisible(self) -> bool: ...
# Note: signatures 1 and 2 overlap unsafely when no arguments are provided # Note: signatures 1 and 2 overlap unsafely when no arguments are provided
@overload @overload
def pen(self) -> _PenState: ... # type: ignore[overload-overlap] def pen(self) -> _PenState: ...
@overload @overload
def pen( def pen(
self, self,
@ -384,7 +384,7 @@ class RawTurtle(TPen, TNavigator):
def shape(self, name: str) -> None: ... def shape(self, name: str) -> None: ...
# Unsafely overlaps when no arguments are provided # Unsafely overlaps when no arguments are provided
@overload @overload
def shapesize(self) -> tuple[float, float, float]: ... # type: ignore[overload-overlap] def shapesize(self) -> tuple[float, float, float]: ...
@overload @overload
def shapesize( def shapesize(
self, stretch_wid: float | None = None, stretch_len: float | None = None, outline: float | None = None self, stretch_wid: float | None = None, stretch_len: float | None = None, outline: float | None = None
@ -395,7 +395,7 @@ class RawTurtle(TPen, TNavigator):
def shearfactor(self, shear: float) -> None: ... def shearfactor(self, shear: float) -> None: ...
# Unsafely overlaps when no arguments are provided # Unsafely overlaps when no arguments are provided
@overload @overload
def shapetransform(self) -> tuple[float, float, float, float]: ... # type: ignore[overload-overlap] def shapetransform(self) -> tuple[float, float, float, float]: ...
@overload @overload
def shapetransform( def shapetransform(
self, t11: float | None = None, t12: float | None = None, t21: float | None = None, t22: float | None = None self, t11: float | None = None, t12: float | None = None, t21: float | None = None, t22: float | None = None
@ -622,7 +622,7 @@ def isvisible() -> bool: ...
# Note: signatures 1 and 2 overlap unsafely when no arguments are provided # Note: signatures 1 and 2 overlap unsafely when no arguments are provided
@overload @overload
def pen() -> _PenState: ... # type: ignore[overload-overlap] def pen() -> _PenState: ...
@overload @overload
def pen( def pen(
pen: _PenState | None = None, pen: _PenState | None = None,
@ -661,7 +661,7 @@ if sys.version_info >= (3, 12):
# Unsafely overlaps when no arguments are provided # Unsafely overlaps when no arguments are provided
@overload @overload
def shapesize() -> tuple[float, float, float]: ... # type: ignore[overload-overlap] def shapesize() -> tuple[float, float, float]: ...
@overload @overload
def shapesize(stretch_wid: float | None = None, stretch_len: float | None = None, outline: float | None = None) -> None: ... def shapesize(stretch_wid: float | None = None, stretch_len: float | None = None, outline: float | None = None) -> None: ...
@overload @overload
@ -671,7 +671,7 @@ def shearfactor(shear: float) -> None: ...
# Unsafely overlaps when no arguments are provided # Unsafely overlaps when no arguments are provided
@overload @overload
def shapetransform() -> tuple[float, float, float, float]: ... # type: ignore[overload-overlap] def shapetransform() -> tuple[float, float, float, float]: ...
@overload @overload
def shapetransform( def shapetransform(
t11: float | None = None, t12: float | None = None, t21: float | None = None, t22: float | None = None t11: float | None = None, t12: float | None = None, t21: float | None = None, t22: float | None = None

View File

@ -305,9 +305,9 @@ class MappingProxyType(Mapping[_KT, _VT_co]):
def values(self) -> ValuesView[_VT_co]: ... def values(self) -> ValuesView[_VT_co]: ...
def items(self) -> ItemsView[_KT, _VT_co]: ... def items(self) -> ItemsView[_KT, _VT_co]: ...
@overload @overload
def get(self, key: _KT, /) -> _VT_co | None: ... # type: ignore[override] def get(self, key: _KT, /) -> _VT_co | None: ...
@overload @overload
def get(self, key: _KT, default: _VT_co | _T2, /) -> _VT_co | _T2: ... # type: ignore[override] def get(self, key: _KT, default: _VT_co | _T2, /) -> _VT_co | _T2: ...
if sys.version_info >= (3, 9): if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __reversed__(self) -> Iterator[_KT]: ... def __reversed__(self) -> Iterator[_KT]: ...
@ -583,7 +583,7 @@ _P = ParamSpec("_P")
# it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable # it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable
@overload @overload
def coroutine(func: Callable[_P, Generator[Any, Any, _R]]) -> Callable[_P, Awaitable[_R]]: ... # type: ignore[overload-overlap] def coroutine(func: Callable[_P, Generator[Any, Any, _R]]) -> Callable[_P, Awaitable[_R]]: ...
@overload @overload
def coroutine(func: _Fn) -> _Fn: ... def coroutine(func: _Fn) -> _Fn: ...

View File

@ -846,7 +846,8 @@ class TextIO(IO[str]):
@abstractmethod @abstractmethod
def __enter__(self) -> TextIO: ... def __enter__(self) -> TextIO: ...
ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview if sys.version_info < (3, 14):
ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview
# Functions # Functions

View File

@ -299,7 +299,7 @@ class _patcher:
# Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock], # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],
# but that's impossible with the current type system. # but that's impossible with the current type system.
@overload @overload
def __call__( # type: ignore[overload-overlap] def __call__(
self, self,
target: str, target: str,
new: _T, new: _T,

View File

@ -198,13 +198,13 @@ else:
# Requires an iterable of length 6 # Requires an iterable of length 6
@overload @overload
def urlunparse(components: Iterable[None]) -> Literal[b""]: ... def urlunparse(components: Iterable[None]) -> Literal[b""]: ... # type: ignore[overload-overlap]
@overload @overload
def urlunparse(components: Iterable[AnyStr | None]) -> AnyStr: ... def urlunparse(components: Iterable[AnyStr | None]) -> AnyStr: ...
# Requires an iterable of length 5 # Requires an iterable of length 5
@overload @overload
def urlunsplit(components: Iterable[None]) -> Literal[b""]: ... def urlunsplit(components: Iterable[None]) -> Literal[b""]: ... # type: ignore[overload-overlap]
@overload @overload
def urlunsplit(components: Iterable[AnyStr | None]) -> AnyStr: ... def urlunsplit(components: Iterable[AnyStr | None]) -> AnyStr: ...
def unwrap(url: str) -> str: ... def unwrap(url: str) -> str: ...

View File

@ -79,6 +79,7 @@ else:
def pathname2url(pathname: str) -> str: ... def pathname2url(pathname: str) -> str: ...
def getproxies() -> dict[str, str]: ... def getproxies() -> dict[str, str]: ...
def getproxies_environment() -> dict[str, str]: ...
def parse_http_list(s: str) -> list[str]: ... def parse_http_list(s: str) -> list[str]: ...
def parse_keqv_list(l: list[str]) -> dict[str, str]: ... def parse_keqv_list(l: list[str]) -> dict[str, str]: ...

View File

@ -1,4 +1,4 @@
from typing import Any from typing import Any, Final
from .domreg import getDOMImplementation as getDOMImplementation, registerDOMImplementation as registerDOMImplementation from .domreg import getDOMImplementation as getDOMImplementation, registerDOMImplementation as registerDOMImplementation
@ -17,22 +17,22 @@ class Node:
NOTATION_NODE: int NOTATION_NODE: int
# ExceptionCode # ExceptionCode
INDEX_SIZE_ERR: int INDEX_SIZE_ERR: Final[int]
DOMSTRING_SIZE_ERR: int DOMSTRING_SIZE_ERR: Final[int]
HIERARCHY_REQUEST_ERR: int HIERARCHY_REQUEST_ERR: Final[int]
WRONG_DOCUMENT_ERR: int WRONG_DOCUMENT_ERR: Final[int]
INVALID_CHARACTER_ERR: int INVALID_CHARACTER_ERR: Final[int]
NO_DATA_ALLOWED_ERR: int NO_DATA_ALLOWED_ERR: Final[int]
NO_MODIFICATION_ALLOWED_ERR: int NO_MODIFICATION_ALLOWED_ERR: Final[int]
NOT_FOUND_ERR: int NOT_FOUND_ERR: Final[int]
NOT_SUPPORTED_ERR: int NOT_SUPPORTED_ERR: Final[int]
INUSE_ATTRIBUTE_ERR: int INUSE_ATTRIBUTE_ERR: Final[int]
INVALID_STATE_ERR: int INVALID_STATE_ERR: Final[int]
SYNTAX_ERR: int SYNTAX_ERR: Final[int]
INVALID_MODIFICATION_ERR: int INVALID_MODIFICATION_ERR: Final[int]
NAMESPACE_ERR: int NAMESPACE_ERR: Final[int]
INVALID_ACCESS_ERR: int INVALID_ACCESS_ERR: Final[int]
VALIDATION_ERR: int VALIDATION_ERR: Final[int]
class DOMException(Exception): class DOMException(Exception):
code: int code: int
@ -62,8 +62,8 @@ class UserDataHandler:
NODE_DELETED: int NODE_DELETED: int
NODE_RENAMED: int NODE_RENAMED: int
XML_NAMESPACE: str XML_NAMESPACE: Final[str]
XMLNS_NAMESPACE: str XMLNS_NAMESPACE: Final[str]
XHTML_NAMESPACE: str XHTML_NAMESPACE: Final[str]
EMPTY_NAMESPACE: None EMPTY_NAMESPACE: Final[None]
EMPTY_PREFIX: None EMPTY_PREFIX: Final[None]

View File

@ -1,14 +1,15 @@
import sys import sys
from _typeshed import FileDescriptorOrPath from _typeshed import FileDescriptorOrPath
from collections.abc import Callable from collections.abc import Callable
from typing import Final
from xml.etree.ElementTree import Element from xml.etree.ElementTree import Element
XINCLUDE: str XINCLUDE: Final[str]
XINCLUDE_INCLUDE: str XINCLUDE_INCLUDE: Final[str]
XINCLUDE_FALLBACK: str XINCLUDE_FALLBACK: Final[str]
if sys.version_info >= (3, 9): if sys.version_info >= (3, 9):
DEFAULT_MAX_INCLUSION_DEPTH: int DEFAULT_MAX_INCLUSION_DEPTH: Final = 6
class FatalIncludeError(SyntaxError): ... class FatalIncludeError(SyntaxError): ...

View File

@ -2,7 +2,7 @@ import sys
from _collections_abc import dict_keys from _collections_abc import dict_keys
from _typeshed import FileDescriptorOrPath, ReadableBuffer, SupportsRead, SupportsWrite from _typeshed import FileDescriptorOrPath, ReadableBuffer, SupportsRead, SupportsWrite
from collections.abc import Callable, Generator, ItemsView, Iterable, Iterator, Mapping, Sequence from collections.abc import Callable, Generator, ItemsView, Iterable, Iterator, Mapping, Sequence
from typing import Any, Literal, SupportsIndex, TypeVar, overload from typing import Any, Final, Literal, SupportsIndex, TypeVar, overload
from typing_extensions import TypeAlias, TypeGuard, deprecated from typing_extensions import TypeAlias, TypeGuard, deprecated
__all__ = [ __all__ = [
@ -41,7 +41,7 @@ _FileRead: TypeAlias = FileDescriptorOrPath | SupportsRead[bytes] | SupportsRead
_FileWriteC14N: TypeAlias = FileDescriptorOrPath | SupportsWrite[bytes] _FileWriteC14N: TypeAlias = FileDescriptorOrPath | SupportsWrite[bytes]
_FileWrite: TypeAlias = _FileWriteC14N | SupportsWrite[str] _FileWrite: TypeAlias = _FileWriteC14N | SupportsWrite[str]
VERSION: str VERSION: Final[str]
class ParseError(SyntaxError): class ParseError(SyntaxError):
code: int code: int

View File

@ -94,6 +94,20 @@ class ZipExtFile(io.BufferedIOBase):
class _Writer(Protocol): class _Writer(Protocol):
def write(self, s: str, /) -> object: ... def write(self, s: str, /) -> object: ...
class _ZipReadable(Protocol):
def seek(self, offset: int, whence: int = 0, /) -> int: ...
def read(self, n: int = -1, /) -> bytes: ...
class _ZipTellable(Protocol):
def tell(self) -> int: ...
class _ZipReadableTellable(_ZipReadable, _ZipTellable, Protocol): ...
class _ZipWritable(Protocol):
def flush(self) -> None: ...
def close(self) -> None: ...
def write(self, b: bytes, /) -> int: ...
class ZipFile: class ZipFile:
filename: str | None filename: str | None
debug: int debug: int
@ -106,24 +120,50 @@ class ZipFile:
compresslevel: int | None # undocumented compresslevel: int | None # undocumented
mode: _ZipFileMode # undocumented mode: _ZipFileMode # undocumented
pwd: bytes | None # undocumented pwd: bytes | None # undocumented
# metadata_encoding is new in 3.11
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
@overload @overload
def __init__( def __init__(
self, self,
file: StrPath | IO[bytes], file: StrPath | IO[bytes],
mode: _ZipFileMode = "r",
compression: int = 0,
allowZip64: bool = True,
compresslevel: int | None = None,
*,
strict_timestamps: bool = True,
metadata_encoding: str | None = None,
) -> None: ...
# metadata_encoding is only allowed for read mode
@overload
def __init__(
self,
file: StrPath | _ZipReadable,
mode: Literal["r"] = "r", mode: Literal["r"] = "r",
compression: int = 0, compression: int = 0,
allowZip64: bool = True, allowZip64: bool = True,
compresslevel: int | None = None, compresslevel: int | None = None,
*, *,
strict_timestamps: bool = True, strict_timestamps: bool = True,
metadata_encoding: str | None, metadata_encoding: str | None = None,
) -> None: ... ) -> None: ...
@overload @overload
def __init__( def __init__(
self, self,
file: StrPath | IO[bytes], file: StrPath | _ZipWritable,
mode: _ZipFileMode = "r", mode: Literal["w", "x"] = ...,
compression: int = 0,
allowZip64: bool = True,
compresslevel: int | None = None,
*,
strict_timestamps: bool = True,
metadata_encoding: None = None,
) -> None: ...
@overload
def __init__(
self,
file: StrPath | _ZipReadableTellable,
mode: Literal["a"] = ...,
compression: int = 0, compression: int = 0,
allowZip64: bool = True, allowZip64: bool = True,
compresslevel: int | None = None, compresslevel: int | None = None,
@ -132,6 +172,7 @@ class ZipFile:
metadata_encoding: None = None, metadata_encoding: None = None,
) -> None: ... ) -> None: ...
else: else:
@overload
def __init__( def __init__(
self, self,
file: StrPath | IO[bytes], file: StrPath | IO[bytes],
@ -142,6 +183,39 @@ class ZipFile:
*, *,
strict_timestamps: bool = True, strict_timestamps: bool = True,
) -> None: ... ) -> None: ...
@overload
def __init__(
self,
file: StrPath | _ZipReadable,
mode: Literal["r"] = "r",
compression: int = 0,
allowZip64: bool = True,
compresslevel: int | None = None,
*,
strict_timestamps: bool = True,
) -> None: ...
@overload
def __init__(
self,
file: StrPath | _ZipWritable,
mode: Literal["w", "x"] = ...,
compression: int = 0,
allowZip64: bool = True,
compresslevel: int | None = None,
*,
strict_timestamps: bool = True,
) -> None: ...
@overload
def __init__(
self,
file: StrPath | _ZipReadableTellable,
mode: Literal["a"] = ...,
compression: int = 0,
allowZip64: bool = True,
compresslevel: int | None = None,
*,
strict_timestamps: bool = True,
) -> None: ...
def __enter__(self) -> Self: ... def __enter__(self) -> Self: ...
def __exit__( def __exit__(