Skip to content
4 changes: 3 additions & 1 deletion mypy/typeshed/stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...
Expand Down
79 changes: 51 additions & 28 deletions mypy/typeshed/stdlib/_operator.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import sys
from _typeshed import SupportsGetItem
from _typeshed import (
SupportsAdd,
SupportsGetItem,
SupportsMod,
SupportsMul,
SupportsRAdd,
SupportsRMod,
SupportsRMul,
SupportsRSub,
SupportsSub,
)
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
Expand All @@ -8,6 +18,7 @@ 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")
Expand Down Expand Up @@ -58,24 +69,36 @@ 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: ...
def add(a: Any, b: Any, /) -> Any: ...
def and_(a: Any, b: Any, /) -> Any: ...
def floordiv(a: Any, b: Any, /) -> Any: ...
@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 index(a: SupportsIndex, /) -> int: ...
def inv(a: _SupportsInversion[_T_co], /) -> _T_co: ...
def invert(a: _SupportsInversion[_T_co], /) -> _T_co: ...
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 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 neg(a: _SupportsNeg[_T_co], /) -> _T_co: ...
def or_(a: Any, b: Any, /) -> Any: ...
def or_(a, b, /): ...
def pos(a: _SupportsPos[_T_co], /) -> _T_co: ...
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 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 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: ...
Expand All @@ -97,20 +120,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: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_sqlite3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/_ssl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions mypy/typeshed/stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Expand Down
36 changes: 18 additions & 18 deletions mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ...,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/concurrent/futures/process.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/concurrent/interpreters/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/concurrent/interpreters/_queues.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/configparser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading
Loading