diff --git a/misc/typeshed_patches/0001-Revert-operator-changes.patch b/misc/typeshed_patches/0001-Revert-operator-changes.patch new file mode 100644 index 0000000000000..71b0ae9b47abd --- /dev/null +++ b/misc/typeshed_patches/0001-Revert-operator-changes.patch @@ -0,0 +1,91 @@ +From 7f38b86464d59188a87ff8c9913c257e788a2f0b Mon Sep 17 00:00:00 2001 +From: hauntsaninja +Date: Wed, 6 May 2026 19:49:41 -0700 +Subject: [PATCH] Revert operator changes + +--- + mypy/typeshed/stdlib/_operator.pyi | 51 ++++++++---------------------- + 1 file changed, 14 insertions(+), 37 deletions(-) + +diff --git a/mypy/typeshed/stdlib/_operator.pyi b/mypy/typeshed/stdlib/_operator.pyi +index e7d85f811..8c705065b 100644 +--- a/mypy/typeshed/stdlib/_operator.pyi ++++ b/mypy/typeshed/stdlib/_operator.pyi +@@ -1,15 +1,5 @@ + import sys +-from _typeshed import ( +- SupportsAdd, +- SupportsGetItem, +- SupportsMod, +- SupportsMul, +- SupportsRAdd, +- SupportsRMod, +- SupportsRMul, +- SupportsRSub, +- SupportsSub, +-) ++from _typeshed import SupportsGetItem + from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence + from operator import attrgetter as attrgetter, itemgetter as itemgetter, methodcaller as methodcaller + from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeVar, overload, type_check_only +@@ -18,7 +8,6 @@ from typing_extensions import ParamSpec, TypeAlias, TypeIs + _R = TypeVar("_R") + _T = TypeVar("_T") + _T_co = TypeVar("_T_co", covariant=True) +-_T_contra = TypeVar("_T_contra", contravariant=True) + _K = TypeVar("_K") + _V = TypeVar("_V") + _P = ParamSpec("_P") +@@ -69,36 +58,24 @@ def truth(a: object, /) -> bool: ... + def is_(a: object, b: object, /) -> bool: ... + def is_not(a: object, b: object, /) -> bool: ... + def abs(a: SupportsAbs[_T], /) -> _T: ... +-@overload +-def add(a: SupportsAdd[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ... +-@overload +-def add(a: _T_contra, b: SupportsRAdd[_T_contra, _T_co], /) -> _T_co: ... +-def and_(a, b, /): ... +-def floordiv(a, b, /): ... ++def add(a: Any, b: Any, /) -> Any: ... ++def and_(a: Any, b: Any, /) -> Any: ... ++def floordiv(a: Any, b: Any, /) -> Any: ... + def index(a: SupportsIndex, /) -> int: ... + def inv(a: _SupportsInversion[_T_co], /) -> _T_co: ... + def invert(a: _SupportsInversion[_T_co], /) -> _T_co: ... +-def lshift(a, b, /): ... +-@overload +-def mod(a: SupportsMod[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ... +-@overload +-def mod(a: _T_contra, b: SupportsRMod[_T_contra, _T_co], /) -> _T_co: ... +-@overload +-def mul(a: SupportsMul[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ... +-@overload +-def mul(a: _T_contra, b: SupportsRMul[_T_contra, _T_co], /) -> _T_co: ... +-def matmul(a, b, /): ... ++def lshift(a: Any, b: Any, /) -> Any: ... ++def mod(a: Any, b: Any, /) -> Any: ... ++def mul(a: Any, b: Any, /) -> Any: ... ++def matmul(a: Any, b: Any, /) -> Any: ... + def neg(a: _SupportsNeg[_T_co], /) -> _T_co: ... +-def or_(a, b, /): ... ++def or_(a: Any, b: Any, /) -> Any: ... + def pos(a: _SupportsPos[_T_co], /) -> _T_co: ... +-def pow(a, b, /): ... +-def rshift(a, b, /): ... +-@overload +-def sub(a: SupportsSub[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ... +-@overload +-def sub(a: _T_contra, b: SupportsRSub[_T_contra, _T_co], /) -> _T_co: ... +-def truediv(a, b, /): ... +-def xor(a, b, /): ... ++def pow(a: Any, b: Any, /) -> Any: ... ++def rshift(a: Any, b: Any, /) -> Any: ... ++def sub(a: Any, b: Any, /) -> Any: ... ++def truediv(a: Any, b: Any, /) -> Any: ... ++def xor(a: Any, b: Any, /) -> Any: ... + def concat(a: Sequence[_T], b: Sequence[_T], /) -> Sequence[_T]: ... + def contains(a: Container[object], b: object, /) -> bool: ... + def countOf(a: Iterable[object], b: object, /) -> int: ... +-- +2.53.0 + diff --git a/mypy/typeshed/stdlib/_codecs.pyi b/mypy/typeshed/stdlib/_codecs.pyi index 89f97edb9ba81..89cb78c33571d 100644 --- a/mypy/typeshed/stdlib/_codecs.pyi +++ b/mypy/typeshed/stdlib/_codecs.pyi @@ -77,7 +77,9 @@ def ascii_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[st def ascii_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... def charmap_decode(data: ReadableBuffer, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[str, int]: ... def charmap_encode(str: str, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[bytes, int]: ... -def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... + +# Docs say this accepts a bytes-like object, but in practice it also accepts str. +def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ... def escape_encode(data: bytes, errors: str | None = None, /) -> tuple[bytes, int]: ... def latin_1_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... def latin_1_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... diff --git a/mypy/typeshed/stdlib/_io.pyi b/mypy/typeshed/stdlib/_io.pyi index 2d2a60e4dddf1..ed8eff2759a98 100644 --- a/mypy/typeshed/stdlib/_io.pyi +++ b/mypy/typeshed/stdlib/_io.pyi @@ -9,7 +9,7 @@ from types import TracebackType from typing import IO, Any, BinaryIO, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload, type_check_only from typing_extensions import Self, disjoint_base -_T = TypeVar("_T") +_S = TypeVar("_S", bound=str) if sys.version_info >= (3, 14): DEFAULT_BUFFER_SIZE: Final = 131072 @@ -298,4 +298,4 @@ if sys.version_info >= (3, 10): @overload def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]: ... @overload - def text_encoding(encoding: _T, stacklevel: int = 2, /) -> _T: ... + def text_encoding(encoding: _S, stacklevel: int = 2, /) -> _S: ... diff --git a/mypy/typeshed/stdlib/_operator.pyi b/mypy/typeshed/stdlib/_operator.pyi index e1ef5c4bf0678..8c705065bde7d 100644 --- a/mypy/typeshed/stdlib/_operator.pyi +++ b/mypy/typeshed/stdlib/_operator.pyi @@ -97,20 +97,20 @@ def setitem(a: MutableSequence[_T], b: slice[int | None], c: Sequence[_T], /) -> @overload def setitem(a: MutableMapping[_K, _V], b: _K, c: _V, /) -> None: ... def length_hint(obj: object, default: int = 0, /) -> int: ... -def iadd(a: Any, b: Any, /) -> Any: ... -def iand(a: Any, b: Any, /) -> Any: ... -def iconcat(a: Any, b: Any, /) -> Any: ... -def ifloordiv(a: Any, b: Any, /) -> Any: ... -def ilshift(a: Any, b: Any, /) -> Any: ... -def imod(a: Any, b: Any, /) -> Any: ... -def imul(a: Any, b: Any, /) -> Any: ... -def imatmul(a: Any, b: Any, /) -> Any: ... -def ior(a: Any, b: Any, /) -> Any: ... -def ipow(a: Any, b: Any, /) -> Any: ... -def irshift(a: Any, b: Any, /) -> Any: ... -def isub(a: Any, b: Any, /) -> Any: ... -def itruediv(a: Any, b: Any, /) -> Any: ... -def ixor(a: Any, b: Any, /) -> Any: ... +def iadd(a, b, /): ... +def iand(a, b, /): ... +def iconcat(a, b, /): ... +def ifloordiv(a, b, /): ... +def ilshift(a, b, /): ... +def imod(a, b, /): ... +def imul(a, b, /): ... +def imatmul(a, b, /): ... +def ior(a, b, /): ... +def ipow(a, b, /): ... +def irshift(a, b, /): ... +def isub(a, b, /): ... +def itruediv(a, b, /): ... +def ixor(a, b, /): ... if sys.version_info >= (3, 11): def call(obj: Callable[_P, _R], /, *args: _P.args, **kwargs: _P.kwargs) -> _R: ... diff --git a/mypy/typeshed/stdlib/_socket.pyi b/mypy/typeshed/stdlib/_socket.pyi index 372b35f22f175..918bffc7f9085 100644 --- a/mypy/typeshed/stdlib/_socket.pyi +++ b/mypy/typeshed/stdlib/_socket.pyi @@ -741,7 +741,7 @@ class socket: def proto(self) -> int: ... # F811: "Redefinition of unused `timeout`" @property - def timeout(self) -> float | None: ... # noqa: F811 + def timeout(self) -> float | None: ... if sys.platform == "win32": def __init__( self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | bytes | None = None @@ -838,7 +838,7 @@ def inet_ntop(address_family: int, packed_ip: ReadableBuffer, /) -> str: ... def getdefaulttimeout() -> float | None: ... # F811: "Redefinition of unused `timeout`" -def setdefaulttimeout(timeout: float | None, /) -> None: ... # noqa: F811 +def setdefaulttimeout(timeout: float | None, /) -> None: ... if sys.platform != "win32": def sethostname(name: str, /) -> None: ... diff --git a/mypy/typeshed/stdlib/_sqlite3.pyi b/mypy/typeshed/stdlib/_sqlite3.pyi index 437a9c9766829..5361584d6b184 100644 --- a/mypy/typeshed/stdlib/_sqlite3.pyi +++ b/mypy/typeshed/stdlib/_sqlite3.pyi @@ -171,7 +171,7 @@ if sys.version_info >= (3, 11): SQLITE_IOERR_VNODE: Final = 6922 SQLITE_IOERR_WRITE: Final = 778 SQLITE_LIMIT_ATTACHED: Final = 7 - SQLITE_LIMIT_COLUMN: Final = 22 + SQLITE_LIMIT_COLUMN: Final = 2 SQLITE_LIMIT_COMPOUND_SELECT: Final = 4 SQLITE_LIMIT_EXPR_DEPTH: Final = 3 SQLITE_LIMIT_FUNCTION_ARG: Final = 6 diff --git a/mypy/typeshed/stdlib/_ssl.pyi b/mypy/typeshed/stdlib/_ssl.pyi index d8cb9d49e7820..e84b24e8f4db7 100644 --- a/mypy/typeshed/stdlib/_ssl.pyi +++ b/mypy/typeshed/stdlib/_ssl.pyi @@ -183,8 +183,8 @@ CERT_REQUIRED: Final = 2 # verify flags VERIFY_DEFAULT: Final = 0 -VERIFY_CRL_CHECK_LEAF: Final = 0x4 -VERIFY_CRL_CHECK_CHAIN: Final = 0x8 +VERIFY_CRL_CHECK_LEAF: Final = 0x04 +VERIFY_CRL_CHECK_CHAIN: Final = 0x0C VERIFY_X509_STRICT: Final = 0x20 VERIFY_X509_TRUSTED_FIRST: Final = 0x8000 if sys.version_info >= (3, 10): @@ -230,7 +230,7 @@ PROTOCOL_TLSv1_1: Final = 4 PROTOCOL_TLSv1_2: Final = 5 # protocol options -OP_ALL: Final = 0x80000050 +OP_ALL: Final[int] OP_NO_SSLv2: Final = 0x0 OP_NO_SSLv3: Final = 0x2000000 OP_NO_TLSv1: Final = 0x4000000 diff --git a/mypy/typeshed/stdlib/_typeshed/__init__.pyi b/mypy/typeshed/stdlib/_typeshed/__init__.pyi index 89e93ab027069..c006322b81451 100644 --- a/mypy/typeshed/stdlib/_typeshed/__init__.pyi +++ b/mypy/typeshed/stdlib/_typeshed/__init__.pyi @@ -126,6 +126,12 @@ class SupportsMul(Protocol[_T_contra, _T_co]): class SupportsRMul(Protocol[_T_contra, _T_co]): def __rmul__(self, x: _T_contra, /) -> _T_co: ... +class SupportsMod(Protocol[_T_contra, _T_co]): + def __mod__(self, other: _T_contra, /) -> _T_co: ... + +class SupportsRMod(Protocol[_T_contra, _T_co]): + def __rmod__(self, other: _T_contra, /) -> _T_co: ... + class SupportsDivMod(Protocol[_T_contra, _T_co]): def __divmod__(self, other: _T_contra, /) -> _T_co: ... diff --git a/mypy/typeshed/stdlib/argparse.pyi b/mypy/typeshed/stdlib/argparse.pyi index c2a6f36911968..7d4bd1a3a8418 100644 --- a/mypy/typeshed/stdlib/argparse.pyi +++ b/mypy/typeshed/stdlib/argparse.pyi @@ -85,7 +85,7 @@ class _ActionsContainer: const: Any = ..., default: Any = ..., type: _ActionType = ..., - choices: Iterable[_T] | None = ..., + choices: Iterable[Any] | None = ..., # choices must match the type specified required: bool = ..., help: str | None = ..., metavar: str | tuple[str, ...] | None = ..., @@ -170,7 +170,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): usage: str | None = None, description: str | None = None, epilog: str | None = None, - parents: Sequence[ArgumentParser] = [], + parents: Iterable[ArgumentParser] = [], formatter_class: _FormatterClass = ..., prefix_chars: str = "-", fromfile_prefix_chars: str | None = None, @@ -190,7 +190,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): usage: str | None = None, description: str | None = None, epilog: str | None = None, - parents: Sequence[ArgumentParser] = [], + parents: Iterable[ArgumentParser] = [], formatter_class: _FormatterClass = ..., prefix_chars: str = "-", fromfile_prefix_chars: str | None = None, @@ -202,9 +202,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): ) -> None: ... @overload - def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... + def parse_args(self, args: Iterable[str] | None = None, namespace: None = None) -> Namespace: ... @overload - def parse_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ... + def parse_args(self, args: Iterable[str] | None, namespace: _N) -> _N: ... @overload def parse_args(self, *, namespace: _N) -> _N: ... @overload @@ -241,26 +241,26 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def format_usage(self) -> str: ... def format_help(self) -> str: ... @overload - def parse_known_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ... + def parse_known_args(self, args: Iterable[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ... @overload - def parse_known_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ... + def parse_known_args(self, args: Iterable[str] | None, namespace: _N) -> tuple[_N, list[str]]: ... @overload def parse_known_args(self, *, namespace: _N) -> tuple[_N, list[str]]: ... def convert_arg_line_to_args(self, arg_line: str) -> list[str]: ... def exit(self, status: int = 0, message: str | None = None) -> NoReturn: ... def error(self, message: str) -> NoReturn: ... @overload - def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... + def parse_intermixed_args(self, args: Iterable[str] | None = None, namespace: None = None) -> Namespace: ... @overload - def parse_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ... + def parse_intermixed_args(self, args: Iterable[str] | None, namespace: _N) -> _N: ... @overload def parse_intermixed_args(self, *, namespace: _N) -> _N: ... @overload def parse_known_intermixed_args( - self, args: Sequence[str] | None = None, namespace: None = None + self, args: Iterable[str] | None = None, namespace: None = None ) -> tuple[Namespace, list[str]]: ... @overload - def parse_known_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ... + def parse_known_intermixed_args(self, args: Iterable[str] | None, namespace: _N) -> tuple[_N, list[str]]: ... @overload def parse_known_intermixed_args(self, *, namespace: _N) -> tuple[_N, list[str]]: ... # undocumented @@ -346,7 +346,7 @@ class HelpFormatter: def _metavar_formatter(self, action: Action, default_metavar: str) -> Callable[[int], tuple[str, ...]]: ... def _format_args(self, action: Action, default_metavar: str) -> str: ... def _expand_help(self, action: Action) -> str: ... - def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ... + def _iter_indented_subactions(self, action: Action) -> Generator[Action]: ... def _split_lines(self, text: str, width: int) -> list[str]: ... def _fill_text(self, text: str, width: int, indent: str) -> str: ... def _get_help_string(self, action: Action) -> str | None: ... @@ -785,13 +785,13 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): *, deprecated: bool = False, help: str | None = ..., - aliases: Sequence[str] = ..., + aliases: Iterable[str] = ..., # Kwargs from ArgumentParser constructor prog: str | None = ..., usage: str | None = ..., description: str | None = ..., epilog: str | None = ..., - parents: Sequence[_ArgumentParserT] = ..., + parents: Iterable[_ArgumentParserT] = ..., formatter_class: _FormatterClass = ..., prefix_chars: str = ..., fromfile_prefix_chars: str | None = ..., @@ -811,13 +811,13 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): *, deprecated: bool = False, help: str | None = ..., - aliases: Sequence[str] = ..., + aliases: Iterable[str] = ..., # Kwargs from ArgumentParser constructor prog: str | None = ..., usage: str | None = ..., description: str | None = ..., epilog: str | None = ..., - parents: Sequence[_ArgumentParserT] = ..., + parents: Iterable[_ArgumentParserT] = ..., formatter_class: _FormatterClass = ..., prefix_chars: str = ..., fromfile_prefix_chars: str | None = ..., @@ -834,13 +834,13 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): name: str, *, help: str | None = ..., - aliases: Sequence[str] = ..., + aliases: Iterable[str] = ..., # Kwargs from ArgumentParser constructor prog: str | None = ..., usage: str | None = ..., description: str | None = ..., epilog: str | None = ..., - parents: Sequence[_ArgumentParserT] = ..., + parents: Iterable[_ArgumentParserT] = ..., formatter_class: _FormatterClass = ..., prefix_chars: str = ..., fromfile_prefix_chars: str | None = ..., diff --git a/mypy/typeshed/stdlib/codecs.pyi b/mypy/typeshed/stdlib/codecs.pyi index 4dfe3fd9e8510..9164a4a626d4f 100644 --- a/mypy/typeshed/stdlib/codecs.pyi +++ b/mypy/typeshed/stdlib/codecs.pyi @@ -196,8 +196,8 @@ def open( filename: str, mode: str = "r", encoding: str | None = None, errors: str = "strict", buffering: int = -1 ) -> StreamReaderWriter: ... def EncodedFile(file: _Stream, data_encoding: str, file_encoding: str | None = None, errors: str = "strict") -> StreamRecoder: ... -def iterencode(iterator: Iterable[str], encoding: str, errors: str = "strict") -> Generator[bytes, None, None]: ... -def iterdecode(iterator: Iterable[bytes], encoding: str, errors: str = "strict") -> Generator[str, None, None]: ... +def iterencode(iterator: Iterable[str], encoding: str, errors: str = "strict") -> Generator[bytes]: ... +def iterdecode(iterator: Iterable[bytes], encoding: str, errors: str = "strict") -> Generator[str]: ... BOM: Final[Literal[b"\xff\xfe", b"\xfe\xff"]] # depends on `sys.byteorder` BOM_BE: Final = b"\xfe\xff" diff --git a/mypy/typeshed/stdlib/concurrent/futures/process.pyi b/mypy/typeshed/stdlib/concurrent/futures/process.pyi index 071b3aba5d330..282bafa0b611c 100644 --- a/mypy/typeshed/stdlib/concurrent/futures/process.pyi +++ b/mypy/typeshed/stdlib/concurrent/futures/process.pyi @@ -97,7 +97,7 @@ class _SafeQueue(Queue[Future[Any]]): def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ... -def _get_chunks(*iterables: Any, chunksize: int) -> Generator[tuple[Any, ...], None, None]: ... +def _get_chunks(*iterables: Any, chunksize: int) -> Generator[tuple[Any, ...]]: ... def _process_chunk(fn: Callable[..., _T], chunk: Iterable[tuple[Any, ...]]) -> list[_T]: ... if sys.version_info >= (3, 11): diff --git a/mypy/typeshed/stdlib/concurrent/interpreters/__init__.pyi b/mypy/typeshed/stdlib/concurrent/interpreters/__init__.pyi index 3839e6bef09b6..171fadb2202be 100644 --- a/mypy/typeshed/stdlib/concurrent/interpreters/__init__.pyi +++ b/mypy/typeshed/stdlib/concurrent/interpreters/__init__.pyi @@ -5,7 +5,7 @@ from collections.abc import Callable from typing import Any, Literal, TypeVar from typing_extensions import ParamSpec, Self -if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13 +if sys.version_info >= (3, 14): # needed to satisfy pyright checks for Python <= 3.13 from _interpreters import ( InterpreterError as InterpreterError, InterpreterNotFoundError as InterpreterNotFoundError, diff --git a/mypy/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi b/mypy/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi index 7cf1ea34786ed..50fe7cf0b4ba4 100644 --- a/mypy/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi +++ b/mypy/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi @@ -3,7 +3,7 @@ from collections.abc import Callable from typing import Final, NewType from typing_extensions import Never, Self, TypeAlias -if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13 +if sys.version_info >= (3, 14): # needed to satisfy pyright checks for Python <= 3.13 from _interpqueues import _UnboundOp class ItemInterpreterDestroyed(Exception): ... diff --git a/mypy/typeshed/stdlib/concurrent/interpreters/_queues.pyi b/mypy/typeshed/stdlib/concurrent/interpreters/_queues.pyi index bdf08d93d1e00..b4a4fd56dd45d 100644 --- a/mypy/typeshed/stdlib/concurrent/interpreters/_queues.pyi +++ b/mypy/typeshed/stdlib/concurrent/interpreters/_queues.pyi @@ -3,7 +3,7 @@ import sys from typing import Final, SupportsIndex from typing_extensions import Self -if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13 +if sys.version_info >= (3, 14): # needed to satisfy pyright checks for Python <= 3.13 from _interpqueues import QueueError as QueueError, QueueNotFoundError as QueueNotFoundError from . import _crossinterp diff --git a/mypy/typeshed/stdlib/configparser.pyi b/mypy/typeshed/stdlib/configparser.pyi index 1e11088c3ae7a..9b3f02324b7fd 100644 --- a/mypy/typeshed/stdlib/configparser.pyi +++ b/mypy/typeshed/stdlib/configparser.pyi @@ -289,19 +289,19 @@ class RawConfigParser(_Parser): def getint(self, section: _SectionName, option: str, *, raw: bool = False, vars: _Section | None = None) -> int: ... @overload def getint( - self, section: _SectionName, option: str, *, raw: bool = False, vars: _Section | None = None, fallback: _T = ... + self, section: _SectionName, option: str, *, raw: bool = False, vars: _Section | None = None, fallback: _T ) -> int | _T: ... @overload def getfloat(self, section: _SectionName, option: str, *, raw: bool = False, vars: _Section | None = None) -> float: ... @overload def getfloat( - self, section: _SectionName, option: str, *, raw: bool = False, vars: _Section | None = None, fallback: _T = ... + self, section: _SectionName, option: str, *, raw: bool = False, vars: _Section | None = None, fallback: _T ) -> float | _T: ... @overload def getboolean(self, section: _SectionName, option: str, *, raw: bool = False, vars: _Section | None = None) -> bool: ... @overload def getboolean( - self, section: _SectionName, option: str, *, raw: bool = False, vars: _Section | None = None, fallback: _T = ... + self, section: _SectionName, option: str, *, raw: bool = False, vars: _Section | None = None, fallback: _T ) -> bool | _T: ... def _get_conv( self, diff --git a/mypy/typeshed/stdlib/contextlib.pyi b/mypy/typeshed/stdlib/contextlib.pyi index cf831e5dcae81..0670787a5db1b 100644 --- a/mypy/typeshed/stdlib/contextlib.pyi +++ b/mypy/typeshed/stdlib/contextlib.pyi @@ -165,9 +165,15 @@ class _BaseExitStack(Generic[_ExitT_co]): def callback(self, callback: Callable[_P, _T], /, *args: _P.args, **kwds: _P.kwargs) -> Callable[_P, _T]: ... def pop_all(self) -> Self: ... -# In reality this is a subclass of `AbstractContextManager`; -# see #7961 for why we don't do that in the stub -class ExitStack(_BaseExitStack[_ExitT_co], metaclass=abc.ABCMeta): +# this class is to avoid putting `metaclass=abc.ABCMeta` on the implementations directly, as this would make them +# appear explicitly abstract to some tools. this is due to the implementations not subclassing `AbstractContextManager` +# see note on the subclasses +@type_check_only +class _BaseExitStackAbstract(_BaseExitStack[_ExitT_co], metaclass=abc.ABCMeta): ... + +# In reality this is a subclass of `AbstractContextManager`, but we can't provide `Self` as the argument for `__enter__` +# https://discuss.python.org/t/self-as-typevar-default/90939 +class ExitStack(_BaseExitStackAbstract[_ExitT_co]): def close(self) -> None: ... def __enter__(self) -> Self: ... def __exit__( @@ -179,9 +185,9 @@ _ExitCoroFunc: TypeAlias = Callable[ ] _ACM_EF = TypeVar("_ACM_EF", bound=AbstractAsyncContextManager[Any, Any] | _ExitCoroFunc) -# In reality this is a subclass of `AbstractAsyncContextManager`; -# see #7961 for why we don't do that in the stub -class AsyncExitStack(_BaseExitStack[_ExitT_co], metaclass=abc.ABCMeta): +# In reality this is a subclass of `AbstractContextManager`, but we can't provide `Self` as the argument for `__enter__` +# https://discuss.python.org/t/self-as-typevar-default/90939 +class AsyncExitStack(_BaseExitStackAbstract[_ExitT_co]): async def enter_async_context(self, cm: AbstractAsyncContextManager[_T, _ExitT_co]) -> _T: ... def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ... def push_async_callback( diff --git a/mypy/typeshed/stdlib/email/message.pyi b/mypy/typeshed/stdlib/email/message.pyi index 794882b140e61..08ba88b4ee6da 100644 --- a/mypy/typeshed/stdlib/email/message.pyi +++ b/mypy/typeshed/stdlib/email/message.pyi @@ -130,7 +130,7 @@ class Message(Generic[_HeaderT_co, _HeaderParamT_contra]): def get_charsets(self, failobj: None = None) -> list[str | None]: ... @overload def get_charsets(self, failobj: _T) -> list[str | _T]: ... - def walk(self) -> Generator[Self, None, None]: ... + def walk(self) -> Generator[Self]: ... def get_content_disposition(self) -> str | None: ... def as_string(self, unixfrom: bool = False, maxheaderlen: int = 0, policy: Policy[Any] | None = None) -> str: ... def as_bytes(self, unixfrom: bool = False, policy: Policy[Any] | None = None) -> bytes: ... @@ -151,13 +151,15 @@ class Message(Generic[_HeaderT_co, _HeaderParamT_contra]): class MIMEPart(Message[_HeaderRegistryT_co, _HeaderRegistryParamT_contra]): def __init__(self, policy: Policy[Any] | None = None) -> None: ... - def get_body(self, preferencelist: Sequence[str] = ("related", "html", "plain")) -> MIMEPart[_HeaderRegistryT_co] | None: ... + def get_body( + self, preferencelist: Sequence[str] = ("related", "html", "plain") + ) -> MIMEPart[_HeaderRegistryT_co, _HeaderRegistryParamT_contra] | None: ... def attach(self, payload: Self) -> None: ... # type: ignore[override] # 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 # cause unforseen consequences. def iter_attachments(self) -> Iterator[Self]: ... - def iter_parts(self) -> Iterator[MIMEPart[_HeaderRegistryT_co]]: ... + def iter_parts(self) -> Iterator[MIMEPart[_HeaderRegistryT_co, _HeaderRegistryParamT_contra]]: ... 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 make_related(self, boundary: str | None = None) -> None: ... @@ -171,4 +173,4 @@ class MIMEPart(Message[_HeaderRegistryT_co, _HeaderRegistryParamT_contra]): def as_string(self, unixfrom: bool = False, maxheaderlen: int | None = None, policy: Policy[Any] | None = None) -> str: ... def is_attachment(self) -> bool: ... -class EmailMessage(MIMEPart): ... +class EmailMessage(MIMEPart[_HeaderRegistryT_co, _HeaderRegistryParamT_contra]): ... diff --git a/mypy/typeshed/stdlib/json/__init__.pyi b/mypy/typeshed/stdlib/json/__init__.pyi index 63e9718ee1512..454a235ecf703 100644 --- a/mypy/typeshed/stdlib/json/__init__.pyi +++ b/mypy/typeshed/stdlib/json/__init__.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsRead, SupportsWrite from collections.abc import Callable -from typing import Any +from typing import Any, Literal from .decoder import JSONDecodeError as JSONDecodeError, JSONDecoder as JSONDecoder from .encoder import JSONEncoder as JSONEncoder @@ -58,4 +58,6 @@ def load( object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, **kwds: Any, ) -> Any: ... -def detect_encoding(b: bytes | bytearray) -> str: ... # undocumented +def detect_encoding( + b: bytes | bytearray, +) -> Literal["utf-8", "utf-8-sig", "utf-16", "utf-16-be", "utf-16-le", "utf-32", "utf-32-be", "utf-32-le"]: ... # undocumented diff --git a/mypy/typeshed/stdlib/lib2to3/fixes/fix_except.pyi b/mypy/typeshed/stdlib/lib2to3/fixes/fix_except.pyi index 30930a2c381e9..0d856e6b0b7d2 100644 --- a/mypy/typeshed/stdlib/lib2to3/fixes/fix_except.pyi +++ b/mypy/typeshed/stdlib/lib2to3/fixes/fix_except.pyi @@ -6,7 +6,7 @@ from ..pytree import Base _N = TypeVar("_N", bound=Base) -def find_excepts(nodes: Iterable[_N]) -> Generator[tuple[_N, _N], None, None]: ... +def find_excepts(nodes: Iterable[_N]) -> Generator[tuple[_N, _N]]: ... class FixExcept(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] diff --git a/mypy/typeshed/stdlib/lib2to3/fixes/fix_import.pyi b/mypy/typeshed/stdlib/lib2to3/fixes/fix_import.pyi index bf4b2d00925eb..2daa18327ec09 100644 --- a/mypy/typeshed/stdlib/lib2to3/fixes/fix_import.pyi +++ b/mypy/typeshed/stdlib/lib2to3/fixes/fix_import.pyi @@ -5,7 +5,7 @@ from typing import ClassVar, Literal from .. import fixer_base from ..pytree import Node -def traverse_imports(names) -> Generator[str, None, None]: ... +def traverse_imports(names) -> Generator[str]: ... class FixImport(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] diff --git a/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi b/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi index c747af529f440..d86ebbe215a14 100644 --- a/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi +++ b/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi @@ -8,7 +8,7 @@ from ..pytree import Node MAPPING: Final[dict[str, str]] def alternates(members): ... -def build_pattern(mapping=...) -> Generator[str, None, None]: ... +def build_pattern(mapping=...) -> Generator[str]: ... class FixImports(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] diff --git a/mypy/typeshed/stdlib/lib2to3/fixes/fix_metaclass.pyi b/mypy/typeshed/stdlib/lib2to3/fixes/fix_metaclass.pyi index 1b1ec82032b4f..6ad25e9aac368 100644 --- a/mypy/typeshed/stdlib/lib2to3/fixes/fix_metaclass.pyi +++ b/mypy/typeshed/stdlib/lib2to3/fixes/fix_metaclass.pyi @@ -8,7 +8,7 @@ def has_metaclass(parent): ... def fixup_parse_tree(cls_node) -> None: ... def fixup_simple_stmt(parent, i, stmt_node) -> None: ... def remove_trailing_newline(node) -> None: ... -def find_metas(cls_node) -> Generator[tuple[Base, int, Base], None, None]: ... +def find_metas(cls_node) -> Generator[tuple[Base, int, Base]]: ... def fixup_indent(suite) -> None: ... class FixMetaclass(fixer_base.BaseFix): diff --git a/mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi b/mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi index 652d8f15ea1a9..f095b3083ba8b 100644 --- a/mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi +++ b/mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi @@ -7,7 +7,7 @@ MAPPING: Final[dict[str, dict[str, str]]] LOOKUP: Final[dict[tuple[str, str], str]] def alternates(members): ... -def build_pattern() -> Generator[str, None, None]: ... +def build_pattern() -> Generator[str]: ... class FixRenames(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] diff --git a/mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi b/mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi index abdcc0f62970f..ab84114f90ea3 100644 --- a/mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi +++ b/mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi @@ -5,7 +5,7 @@ from .fix_imports import FixImports MAPPING: Final[dict[str, list[tuple[Literal["urllib.request", "urllib.parse", "urllib.error"], list[str]]]]] -def build_pattern() -> Generator[str, None, None]: ... +def build_pattern() -> Generator[str]: ... class FixUrllib(FixImports): def build_pattern(self): ... diff --git a/mypy/typeshed/stdlib/lib2to3/refactor.pyi b/mypy/typeshed/stdlib/lib2to3/refactor.pyi index a7f3825406488..c33347ede38fd 100644 --- a/mypy/typeshed/stdlib/lib2to3/refactor.pyi +++ b/mypy/typeshed/stdlib/lib2to3/refactor.pyi @@ -69,8 +69,8 @@ class RefactoringTool: def parse_block(self, block: Iterable[str], lineno: int, indent: int) -> Node: ... def wrap_toks( self, block: Iterable[str], lineno: int, indent: int - ) -> Generator[tuple[int, str, tuple[int, int], tuple[int, int], str], None, None]: ... - def gen_lines(self, block: Iterable[str], indent: int) -> Generator[str, None, None]: ... + ) -> Generator[tuple[int, str, tuple[int, int], tuple[int, int], str]]: ... + def gen_lines(self, block: Iterable[str], indent: int) -> Generator[str]: ... class MultiprocessingUnsupported(Exception): ... diff --git a/mypy/typeshed/stdlib/os/__init__.pyi b/mypy/typeshed/stdlib/os/__init__.pyi index 9e02fbf9e1066..66a9d1dd3bc6d 100644 --- a/mypy/typeshed/stdlib/os/__init__.pyi +++ b/mypy/typeshed/stdlib/os/__init__.pyi @@ -614,9 +614,12 @@ if sys.platform == "darwin" and sys.version_info >= (3, 12): SEEK_SET: Final = 0 SEEK_CUR: Final = 1 SEEK_END: Final = 2 -if sys.platform != "win32": +if sys.platform == "linux": SEEK_DATA: Final = 3 SEEK_HOLE: Final = 4 +elif sys.platform == "darwin": + SEEK_HOLE: Final = 3 + SEEK_DATA: Final = 4 O_RDONLY: Final[int] O_WRONLY: Final[int] @@ -826,11 +829,9 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) if sys.version_info >= (3, 12) and sys.platform == "win32": @property - @deprecated( - """\ + @deprecated("""\ Use st_birthtime instead to retrieve the file creation time. \ -In the future, this property will contain the last metadata change time.""" - ) +In the future, this property will contain the last metadata change time.""") def st_ctime(self) -> float: ... else: @property @@ -1531,7 +1532,36 @@ else: def WSTOPSIG(status: int) -> int: ... def WTERMSIG(status: int) -> int: ... - if sys.version_info >= (3, 13): + if sys.version_info >= (3, 15): + def posix_spawn( + path: StrOrBytesPath, + argv: _ExecVArgs, + env: _ExecEnv | None, + /, + *, + file_actions: Sequence[tuple[Any, ...]] | None = (), + setpgroup: int | None = None, # None allowed starting in 3.15 + resetids: bool = False, + setsid: bool = False, + setsigmask: Iterable[int] = (), + setsigdef: Iterable[int] = (), + scheduler: tuple[Any, sched_param] | None = None, # None allowed starting in 3.15 + ) -> int: ... + def posix_spawnp( + path: StrOrBytesPath, + argv: _ExecVArgs, + env: _ExecEnv | None, + /, + *, + file_actions: Sequence[tuple[Any, ...]] | None = (), + setpgroup: int | None = None, # None allowed starting in 3.15 + resetids: bool = False, + setsid: bool = False, + setsigmask: Iterable[int] = (), + setsigdef: Iterable[int] = (), + scheduler: tuple[Any, sched_param] | None = None, # None allowed starting in 3.15 + ) -> int: ... + elif sys.version_info >= (3, 13): def posix_spawn( path: StrOrBytesPath, argv: _ExecVArgs, diff --git a/mypy/typeshed/stdlib/pathlib/__init__.pyi b/mypy/typeshed/stdlib/pathlib/__init__.pyi index 26dde2accd8dd..4f094130665c8 100644 --- a/mypy/typeshed/stdlib/pathlib/__init__.pyi +++ b/mypy/typeshed/stdlib/pathlib/__init__.pyi @@ -189,11 +189,11 @@ class Path(PurePath): self, pattern: str, *, case_sensitive: bool | None = None, recurse_symlinks: bool = False ) -> Iterator[Self]: ... elif sys.version_info >= (3, 12): - def glob(self, pattern: str, *, case_sensitive: bool | None = None) -> Generator[Self, None, None]: ... - def rglob(self, pattern: str, *, case_sensitive: bool | None = None) -> Generator[Self, None, None]: ... + def glob(self, pattern: str, *, case_sensitive: bool | None = None) -> Generator[Self]: ... + def rglob(self, pattern: str, *, case_sensitive: bool | None = None) -> Generator[Self]: ... else: - def glob(self, pattern: str) -> Generator[Self, None, None]: ... - def rglob(self, pattern: str) -> Generator[Self, None, None]: ... + def glob(self, pattern: str) -> Generator[Self]: ... + def rglob(self, pattern: str) -> Generator[Self]: ... if sys.version_info >= (3, 12): def exists(self, *, follow_symlinks: bool = True) -> bool: ... @@ -208,7 +208,7 @@ class Path(PurePath): if sys.version_info >= (3, 12): def is_junction(self) -> bool: ... - def iterdir(self) -> Generator[Self, None, None]: ... + def iterdir(self) -> Generator[Self]: ... def lchmod(self, mode: int) -> None: ... def lstat(self) -> stat_result: ... def mkdir(self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False) -> None: ... diff --git a/mypy/typeshed/stdlib/sqlite3/__init__.pyi b/mypy/typeshed/stdlib/sqlite3/__init__.pyi index f12f80a35a975..ec37eed8c9277 100644 --- a/mypy/typeshed/stdlib/sqlite3/__init__.pyi +++ b/mypy/typeshed/stdlib/sqlite3/__init__.pyi @@ -365,9 +365,9 @@ class Connection: def executescript(self, sql_script: str, /) -> Cursor: ... def interrupt(self) -> None: ... if sys.version_info >= (3, 13): - def iterdump(self, *, filter: str | None = None) -> Generator[str, None, None]: ... + def iterdump(self, *, filter: str | None = None) -> Generator[str]: ... else: - def iterdump(self) -> Generator[str, None, None]: ... + def iterdump(self) -> Generator[str]: ... def rollback(self) -> None: ... def set_authorizer( diff --git a/mypy/typeshed/stdlib/ssl.pyi b/mypy/typeshed/stdlib/ssl.pyi index 2053005f1ba69..57952cf19bbed 100644 --- a/mypy/typeshed/stdlib/ssl.pyi +++ b/mypy/typeshed/stdlib/ssl.pyi @@ -103,14 +103,14 @@ CERT_OPTIONAL: Final = VerifyMode.CERT_OPTIONAL CERT_REQUIRED: Final = VerifyMode.CERT_REQUIRED class VerifyFlags(enum.IntFlag): - VERIFY_DEFAULT = 0 - VERIFY_CRL_CHECK_LEAF = 4 - VERIFY_CRL_CHECK_CHAIN = 12 - VERIFY_X509_STRICT = 32 - VERIFY_X509_TRUSTED_FIRST = 32768 + VERIFY_DEFAULT = 0x00 + VERIFY_CRL_CHECK_LEAF = 0x04 + VERIFY_CRL_CHECK_CHAIN = 0x0C + VERIFY_X509_STRICT = 0x20 + VERIFY_X509_TRUSTED_FIRST = 0x8000 if sys.version_info >= (3, 10): - VERIFY_ALLOW_PROXY_CERTS = 64 - VERIFY_X509_PARTIAL_CHAIN = 524288 + VERIFY_ALLOW_PROXY_CERTS = 0x40 + VERIFY_X509_PARTIAL_CHAIN = 0x80000 VERIFY_DEFAULT: Final = VerifyFlags.VERIFY_DEFAULT VERIFY_CRL_CHECK_LEAF: Final = VerifyFlags.VERIFY_CRL_CHECK_LEAF @@ -144,7 +144,7 @@ PROTOCOL_TLS_CLIENT: Final = _SSLMethod.PROTOCOL_TLS_CLIENT PROTOCOL_TLS_SERVER: Final = _SSLMethod.PROTOCOL_TLS_SERVER class Options(enum.IntFlag): - OP_ALL = 2147483728 + OP_ALL: int OP_NO_SSLv2 = 0 OP_NO_SSLv3 = 33554432 OP_NO_TLSv1 = 67108864 diff --git a/mypy/typeshed/stdlib/tokenize.pyi b/mypy/typeshed/stdlib/tokenize.pyi index 00a24b4eea07d..0df8062d56891 100644 --- a/mypy/typeshed/stdlib/tokenize.pyi +++ b/mypy/typeshed/stdlib/tokenize.pyi @@ -151,8 +151,8 @@ class Untokenizer: # Returns str, unless the ENCODING token is present, in which case it returns bytes. def untokenize(iterable: Iterable[_Token]) -> str | Any: ... def detect_encoding(readline: Callable[[], bytes | bytearray]) -> tuple[str, Sequence[bytes]]: ... -def tokenize(readline: Callable[[], bytes | bytearray]) -> Generator[TokenInfo, None, None]: ... -def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... +def tokenize(readline: Callable[[], bytes | bytearray]) -> Generator[TokenInfo]: ... +def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo]: ... def open(filename: FileDescriptorOrPath) -> TextIO: ... def group(*choices: str) -> str: ... # undocumented def any(*choices: str) -> str: ... # undocumented diff --git a/mypy/typeshed/stdlib/traceback.pyi b/mypy/typeshed/stdlib/traceback.pyi index 4305706afa20b..f9d88f25afd97 100644 --- a/mypy/typeshed/stdlib/traceback.pyi +++ b/mypy/typeshed/stdlib/traceback.pyi @@ -111,7 +111,7 @@ def walk_tb(tb: TracebackType | None) -> Iterator[tuple[FrameType, int]]: ... if sys.version_info >= (3, 11): class _ExceptionPrintContext: def indent(self) -> str: ... - def emit(self, text_gen: str | Iterable[str], margin_char: str | None = None) -> Generator[str, None, None]: ... + def emit(self, text_gen: str | Iterable[str], margin_char: str | None = None) -> Generator[str]: ... class TracebackException: __cause__: TracebackException | None @@ -232,14 +232,14 @@ class TracebackException: def __eq__(self, other: object) -> bool: ... __hash__: ClassVar[None] # type: ignore[assignment] if sys.version_info >= (3, 11): - def format(self, *, chain: bool = True, _ctx: _ExceptionPrintContext | None = None) -> Generator[str, None, None]: ... + def format(self, *, chain: bool = True, _ctx: _ExceptionPrintContext | None = None) -> Generator[str]: ... else: - def format(self, *, chain: bool = True) -> Generator[str, None, None]: ... + def format(self, *, chain: bool = True) -> Generator[str]: ... if sys.version_info >= (3, 13): - def format_exception_only(self, *, show_group: bool = False, _depth: int = 0) -> Generator[str, None, None]: ... + def format_exception_only(self, *, show_group: bool = False, _depth: int = 0) -> Generator[str]: ... else: - def format_exception_only(self) -> Generator[str, None, None]: ... + def format_exception_only(self) -> Generator[str]: ... if sys.version_info >= (3, 11): def print(self, *, file: SupportsWrite[str] | None = None, chain: bool = True) -> None: ... diff --git a/mypy/typeshed/stdlib/typing_extensions.pyi b/mypy/typeshed/stdlib/typing_extensions.pyi index 16cf0611a58ad..406005cc4c561 100644 --- a/mypy/typeshed/stdlib/typing_extensions.pyi +++ b/mypy/typeshed/stdlib/typing_extensions.pyi @@ -220,7 +220,7 @@ def runtime_checkable(cls: _TC) -> _TC: ... runtime = runtime_checkable Final: _SpecialForm -def final(f: _F) -> _F: ... +def final(f: _T) -> _T: ... def disjoint_base(cls: _TC) -> _TC: ... Literal: _SpecialForm diff --git a/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi b/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi index 80f3c55c14899..5c03dd014b639 100644 --- a/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi +++ b/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi @@ -8,10 +8,10 @@ xpath_tokenizer_re: Final[Pattern[str]] _Token: TypeAlias = tuple[str, str] _Next: TypeAlias = Callable[[], _Token] -_Callback: TypeAlias = Callable[[_SelectorContext, Iterable[Element]], Generator[Element, None, None]] +_Callback: TypeAlias = Callable[[_SelectorContext, Iterable[Element]], Generator[Element]] _T = TypeVar("_T") -def xpath_tokenizer(pattern: str, namespaces: dict[str, str] | None = None) -> Generator[_Token, None, None]: ... +def xpath_tokenizer(pattern: str, namespaces: dict[str, str] | None = None) -> Generator[_Token]: ... def get_parent_map(context: _SelectorContext) -> dict[Element, Element]: ... def prepare_child(next: _Next, token: _Token) -> _Callback: ... def prepare_star(next: _Next, token: _Token) -> _Callback: ... @@ -32,7 +32,7 @@ def iterfind( # type: ignore[overload-overlap] elem: Element[Any], path: Literal[""], namespaces: dict[str, str] | None = None ) -> None: ... @overload -def iterfind(elem: Element[Any], path: str, namespaces: dict[str, str] | None = None) -> Generator[Element, None, None]: ... +def iterfind(elem: Element[Any], path: str, namespaces: dict[str, str] | None = None) -> Generator[Element]: ... def find(elem: Element[Any], path: str, namespaces: dict[str, str] | None = None) -> Element | None: ... def findall(elem: Element[Any], path: str, namespaces: dict[str, str] | None = None) -> list[Element]: ... @overload diff --git a/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi b/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi index d728fb975bfb9..6340a44bd51c8 100644 --- a/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi +++ b/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi @@ -106,12 +106,12 @@ class Element(Generic[_Tag]): def get(self, key: str, default: _T) -> str | _T: ... def insert(self, index: int, subelement: Element[Any], /) -> None: ... def items(self) -> ItemsView[str, str]: ... - def iter(self, tag: str | None = None) -> Generator[Element, None, None]: ... + def iter(self, tag: str | None = None) -> Generator[Element]: ... @overload def iterfind(self, path: Literal[""], namespaces: dict[str, str] | None = None) -> None: ... # type: ignore[overload-overlap] @overload - def iterfind(self, path: str, namespaces: dict[str, str] | None = None) -> Generator[Element, None, None]: ... - def itertext(self) -> Generator[str, None, None]: ... + def iterfind(self, path: str, namespaces: dict[str, str] | None = None) -> Generator[Element]: ... + def itertext(self) -> Generator[str]: ... def keys(self) -> dict_keys[str, str]: ... # makeelement returns the type of self in Python impl, but not in C impl def makeelement(self, tag: _OtherTag, attrib: dict[str, str], /) -> Element[_OtherTag]: ... @@ -159,7 +159,7 @@ class ElementTree(Generic[_Root]): def getroot(self) -> _Root: ... def _setroot(self, element: Element[Any]) -> None: ... def parse(self, source: _FileRead, parser: XMLParser | None = None) -> Element: ... - def iter(self, tag: str | None = None) -> Generator[Element, None, None]: ... + def iter(self, tag: str | None = None) -> Generator[Element]: ... def find(self, path: str, namespaces: dict[str, str] | None = None) -> Element | None: ... @overload def findtext(self, path: str, default: None = None, namespaces: dict[str, str] | None = None) -> str | None: ... @@ -169,7 +169,7 @@ class ElementTree(Generic[_Root]): @overload def iterfind(self, path: Literal[""], namespaces: dict[str, str] | None = None) -> None: ... # type: ignore[overload-overlap] @overload - def iterfind(self, path: str, namespaces: dict[str, str] | None = None) -> Generator[Element, None, None]: ... + def iterfind(self, path: str, namespaces: dict[str, str] | None = None) -> Generator[Element]: ... def write( self, file_or_filename: _FileWrite,