diff --git a/mypy/typeshed/stdlib/_ctypes.pyi b/mypy/typeshed/stdlib/_ctypes.pyi index 082a31f70562..813aa4434659 100644 --- a/mypy/typeshed/stdlib/_ctypes.pyi +++ b/mypy/typeshed/stdlib/_ctypes.pyi @@ -5,7 +5,7 @@ from abc import abstractmethod from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p from types import GenericAlias -from typing import Any, ClassVar, Final, Generic, TypeVar, final, overload, type_check_only +from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, final, overload, type_check_only from typing_extensions import Self, TypeAlias _T = TypeVar("_T") @@ -266,6 +266,10 @@ class Structure(_CData, metaclass=_PyCStructType): if sys.version_info >= (3, 13): _align_: ClassVar[int] + if sys.version_info >= (3, 14): + # _layout_ can be defined by the user, but is not always present. + _layout_: ClassVar[Literal["ms", "gcc-sysv"]] + def __init__(self, *args: Any, **kw: Any) -> None: ... def __getattr__(self, name: str) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ... diff --git a/mypy/typeshed/stdlib/_winapi.pyi b/mypy/typeshed/stdlib/_winapi.pyi index d9e2c377b115..42efce9bed70 100644 --- a/mypy/typeshed/stdlib/_winapi.pyi +++ b/mypy/typeshed/stdlib/_winapi.pyi @@ -192,6 +192,9 @@ if sys.platform == "win32": template_file: int, /, ) -> int: ... + def CreateFileMapping( + file_handle: int, security_attributes: int, protect: int, max_size_high: int, max_size_low: int, name: str, / + ) -> int: ... def CreateJunction(src_path: str, dst_path: str, /) -> None: ... def CreateNamedPipe( name: str, @@ -235,6 +238,9 @@ if sys.platform == "win32": def GetModuleFileName(module_handle: int, /) -> str: ... def GetStdHandle(std_handle: int, /) -> int: ... def GetVersion() -> int: ... + def MapViewOfFile( + file_map: int, desired_access: int, file_offset_high: int, file_offset_low: int, number_bytes: int, / + ) -> int: ... def OpenProcess(desired_access: int, inherit_handle: bool, process_id: int, /) -> int: ... def PeekNamedPipe(handle: int, size: int = 0, /) -> tuple[int, int] | tuple[bytes, int, int]: ... if sys.version_info >= (3, 10): @@ -251,6 +257,7 @@ if sys.platform == "win32": named_pipe: int, mode: int | None, max_collection_count: int | None, collect_data_timeout: int | None, / ) -> None: ... def TerminateProcess(handle: int, exit_code: int, /) -> None: ... + def VirtualQuerySize(address: int, /) -> int: ... def WaitForMultipleObjects(handle_seq: Sequence[int], wait_flag: bool, milliseconds: int = 0xFFFFFFFF, /) -> int: ... def WaitForSingleObject(handle: int, milliseconds: int, /) -> int: ... def WaitNamedPipe(name: str, timeout: int, /) -> None: ... @@ -281,6 +288,8 @@ if sys.platform == "win32": def ResetEvent(event: int) -> None: ... def SetEvent(event: int) -> None: ... + def OpenFileMapping(desired_access: int, inherit_handle: bool, name: str, /) -> int: ... + if sys.version_info >= (3, 12): def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int: ... def NeedCurrentDirectoryForExePath(exe_name: str, /) -> bool: ... diff --git a/mypy/typeshed/stdlib/_zstd.pyi b/mypy/typeshed/stdlib/_zstd.pyi index f5e98ef88bb9..e40c7d12b6e7 100644 --- a/mypy/typeshed/stdlib/_zstd.pyi +++ b/mypy/typeshed/stdlib/_zstd.pyi @@ -46,7 +46,10 @@ class ZstdCompressor: FLUSH_BLOCK: Final = 1 FLUSH_FRAME: Final = 2 def __new__( - cls, level: int | None = None, options: Mapping[int, int] | None = None, zstd_dict: ZstdDict | None = None + cls, + level: int | None = None, + options: Mapping[int, int] | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, ) -> Self: ... def compress( self, /, data: ReadableBuffer, mode: _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 0 @@ -58,7 +61,9 @@ class ZstdCompressor: @final class ZstdDecompressor: - def __new__(cls, zstd_dict: ZstdDict | None = None, options: Mapping[int, int] | None = None) -> Self: ... + def __new__( + cls, zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, options: Mapping[int, int] | None = None + ) -> Self: ... def decompress(self, /, data: ReadableBuffer, max_length: int = -1) -> bytes: ... @property def eof(self) -> bool: ... diff --git a/mypy/typeshed/stdlib/argparse.pyi b/mypy/typeshed/stdlib/argparse.pyi index f4b3aac09aa9..e2774081fbd7 100644 --- a/mypy/typeshed/stdlib/argparse.pyi +++ b/mypy/typeshed/stdlib/argparse.pyi @@ -251,7 +251,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def _read_args_from_files(self, arg_strings: list[str]) -> list[str]: ... def _match_argument(self, action: Action, arg_strings_pattern: str) -> int: ... def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: str) -> list[int]: ... - def _parse_optional(self, arg_string: str) -> tuple[Action | None, str, str | None] | None: ... + if sys.version_info >= (3, 12): + def _parse_optional(self, arg_string: str) -> list[tuple[Action | None, str, str | None, str | None]] | None: ... + else: + def _parse_optional(self, arg_string: str) -> tuple[Action | None, str, str | None] | None: ... + def _get_option_tuples(self, option_string: str) -> list[tuple[Action, str, str | None]]: ... def _get_nargs_pattern(self, action: Action) -> str: ... def _get_values(self, action: Action, arg_strings: list[str]) -> Any: ... diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi index 30dfb9dbb25c..bd425ff3c212 100644 --- a/mypy/typeshed/stdlib/builtins.pyi +++ b/mypy/typeshed/stdlib/builtins.pyi @@ -633,8 +633,13 @@ class bytes(Sequence[int]): def translate(self, table: ReadableBuffer | None, /, delete: ReadableBuffer = b"") -> bytes: ... def upper(self) -> bytes: ... def zfill(self, width: SupportsIndex, /) -> bytes: ... - @classmethod - def fromhex(cls, string: str, /) -> Self: ... + if sys.version_info >= (3, 14): + @classmethod + def fromhex(cls, string: str | ReadableBuffer, /) -> Self: ... + else: + @classmethod + def fromhex(cls, string: str, /) -> Self: ... + @staticmethod def maketrans(frm: ReadableBuffer, to: ReadableBuffer, /) -> bytes: ... def __len__(self) -> int: ... @@ -738,8 +743,13 @@ class bytearray(MutableSequence[int]): def translate(self, table: ReadableBuffer | None, /, delete: bytes = b"") -> bytearray: ... def upper(self) -> bytearray: ... def zfill(self, width: SupportsIndex, /) -> bytearray: ... - @classmethod - def fromhex(cls, string: str, /) -> Self: ... + if sys.version_info >= (3, 14): + @classmethod + def fromhex(cls, string: str | ReadableBuffer, /) -> Self: ... + else: + @classmethod + def fromhex(cls, string: str, /) -> Self: ... + @staticmethod def maketrans(frm: ReadableBuffer, to: ReadableBuffer, /) -> bytes: ... def __len__(self) -> int: ... @@ -846,11 +856,15 @@ class memoryview(Sequence[_I]): def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = 1) -> str: ... def __buffer__(self, flags: int, /) -> memoryview: ... def __release_buffer__(self, buffer: memoryview, /) -> None: ... + if sys.version_info >= (3, 14): + def index(self, value: object, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int: ... + def count(self, value: object, /) -> int: ... + else: + # These are inherited from the Sequence ABC, but don't actually exist on memoryview. + # See https://github.com/python/cpython/issues/125420 + index: ClassVar[None] # type: ignore[assignment] + count: ClassVar[None] # type: ignore[assignment] - # These are inherited from the Sequence ABC, but don't actually exist on memoryview. - # See https://github.com/python/cpython/issues/125420 - index: ClassVar[None] # type: ignore[assignment] - count: ClassVar[None] # type: ignore[assignment] if sys.version_info >= (3, 14): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... diff --git a/mypy/typeshed/stdlib/compression/zstd/__init__.pyi b/mypy/typeshed/stdlib/compression/zstd/__init__.pyi index d5da4be03612..acfbe4913b5d 100644 --- a/mypy/typeshed/stdlib/compression/zstd/__init__.pyi +++ b/mypy/typeshed/stdlib/compression/zstd/__init__.pyi @@ -44,9 +44,14 @@ def get_frame_info(frame_buffer: ReadableBuffer) -> FrameInfo: ... def train_dict(samples: Iterable[ReadableBuffer], dict_size: int) -> ZstdDict: ... def finalize_dict(zstd_dict: ZstdDict, /, samples: Iterable[ReadableBuffer], dict_size: int, level: int) -> ZstdDict: ... def compress( - data: ReadableBuffer, level: int | None = None, options: Mapping[int, int] | None = None, zstd_dict: ZstdDict | None = None + data: ReadableBuffer, + level: int | None = None, + options: Mapping[int, int] | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, +) -> bytes: ... +def decompress( + data: ReadableBuffer, zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, options: Mapping[int, int] | None = None ) -> bytes: ... -def decompress(data: ReadableBuffer, zstd_dict: ZstdDict | None = None, options: Mapping[int, int] | None = None) -> bytes: ... @final class CompressionParameter(enum.IntEnum): compression_level = _zstd.ZSTD_c_compressionLevel diff --git a/mypy/typeshed/stdlib/compression/zstd/_zstdfile.pyi b/mypy/typeshed/stdlib/compression/zstd/_zstdfile.pyi index e67b3d992f2f..d37e6b174166 100644 --- a/mypy/typeshed/stdlib/compression/zstd/_zstdfile.pyi +++ b/mypy/typeshed/stdlib/compression/zstd/_zstdfile.pyi @@ -36,7 +36,7 @@ class ZstdFile(_streams.BaseStream): *, level: None = None, options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, ) -> None: ... @overload def __init__( @@ -47,7 +47,7 @@ class ZstdFile(_streams.BaseStream): *, level: int | None = None, options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, ) -> None: ... def write(self, data: ReadableBuffer, /) -> int: ... def flush(self, mode: _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 1) -> bytes: ... # type: ignore[override] @@ -71,7 +71,7 @@ def open( *, level: None = None, options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, encoding: str | None = None, errors: str | None = None, newline: str | None = None, @@ -84,7 +84,7 @@ def open( *, level: int | None = None, options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, encoding: str | None = None, errors: str | None = None, newline: str | None = None, @@ -97,7 +97,7 @@ def open( *, level: None = None, options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, encoding: str | None = None, errors: str | None = None, newline: str | None = None, @@ -110,7 +110,7 @@ def open( *, level: int | None = None, options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, encoding: str | None = None, errors: str | None = None, newline: str | None = None, diff --git a/mypy/typeshed/stdlib/heapq.pyi b/mypy/typeshed/stdlib/heapq.pyi index 220c41f303fb..ff8ba7ff1f82 100644 --- a/mypy/typeshed/stdlib/heapq.pyi +++ b/mypy/typeshed/stdlib/heapq.pyi @@ -1,3 +1,4 @@ +import sys from _heapq import * from _typeshed import SupportsRichComparison from collections.abc import Callable, Generator, Iterable @@ -5,6 +6,10 @@ from typing import Any, Final, TypeVar __all__ = ["heappush", "heappop", "heapify", "heapreplace", "merge", "nlargest", "nsmallest", "heappushpop"] +if sys.version_info >= (3, 14): + # Added to __all__ in 3.14.1 + __all__ += ["heapify_max", "heappop_max", "heappush_max", "heappushpop_max", "heapreplace_max"] + _S = TypeVar("_S") __about__: Final[str] diff --git a/mypy/typeshed/stdlib/importlib/readers.pyi b/mypy/typeshed/stdlib/importlib/readers.pyi index 4a6c73921535..0e7f7ce165c3 100644 --- a/mypy/typeshed/stdlib/importlib/readers.pyi +++ b/mypy/typeshed/stdlib/importlib/readers.pyi @@ -52,9 +52,9 @@ if sys.version_info >= (3, 10): def is_file(self) -> Literal[False]: ... if sys.version_info >= (3, 12): - def joinpath(self, *descendants: str) -> abc.Traversable: ... + def joinpath(self, *descendants: StrPath) -> abc.Traversable: ... elif sys.version_info >= (3, 11): - def joinpath(self, child: str) -> abc.Traversable: ... # type: ignore[override] + def joinpath(self, child: StrPath) -> abc.Traversable: ... # type: ignore[override] else: def joinpath(self, child: str) -> abc.Traversable: ... diff --git a/mypy/typeshed/stdlib/importlib/resources/abc.pyi b/mypy/typeshed/stdlib/importlib/resources/abc.pyi index 80d92a608604..9be594a7dc2f 100644 --- a/mypy/typeshed/stdlib/importlib/resources/abc.pyi +++ b/mypy/typeshed/stdlib/importlib/resources/abc.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import StrPath from abc import ABCMeta, abstractmethod from collections.abc import Iterator from io import BufferedReader @@ -24,7 +25,7 @@ if sys.version_info >= (3, 11): @abstractmethod def iterdir(self) -> Iterator[Traversable]: ... @abstractmethod - def joinpath(self, *descendants: str) -> Traversable: ... + def joinpath(self, *descendants: StrPath) -> Traversable: ... # The documentation and runtime protocol allows *args, **kwargs arguments, # but this would mean that all implementers would have to support them, @@ -38,7 +39,7 @@ if sys.version_info >= (3, 11): @property @abstractmethod def name(self) -> str: ... - def __truediv__(self, child: str, /) -> Traversable: ... + def __truediv__(self, child: StrPath, /) -> Traversable: ... @abstractmethod def read_bytes(self) -> bytes: ... @abstractmethod diff --git a/mypy/typeshed/stdlib/importlib/resources/simple.pyi b/mypy/typeshed/stdlib/importlib/resources/simple.pyi index c4c758111c2d..946987c7312f 100644 --- a/mypy/typeshed/stdlib/importlib/resources/simple.pyi +++ b/mypy/typeshed/stdlib/importlib/resources/simple.pyi @@ -1,5 +1,6 @@ import abc import sys +from _typeshed import StrPath from collections.abc import Iterator from io import TextIOWrapper from typing import IO, Any, BinaryIO, Literal, NoReturn, overload @@ -50,7 +51,7 @@ if sys.version_info >= (3, 11): def iterdir(self) -> Iterator[ResourceHandle | ResourceContainer]: ... def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] if sys.version_info < (3, 12): - def joinpath(self, *descendants: str) -> Traversable: ... + def joinpath(self, *descendants: StrPath) -> Traversable: ... class TraversableReader(TraversableResources, SimpleReader, metaclass=abc.ABCMeta): def files(self) -> ResourceContainer: ... diff --git a/mypy/typeshed/stdlib/mmap.pyi b/mypy/typeshed/stdlib/mmap.pyi index 8a5baba62914..98183acba40f 100644 --- a/mypy/typeshed/stdlib/mmap.pyi +++ b/mypy/typeshed/stdlib/mmap.pyi @@ -54,28 +54,28 @@ class mmap: ) -> Self: ... def close(self) -> None: ... - def flush(self, offset: int = 0, size: int = ...) -> None: ... - def move(self, dest: int, src: int, count: int) -> None: ... + def flush(self, offset: int = 0, size: int = ..., /) -> None: ... + def move(self, dest: int, src: int, count: int, /) -> None: ... def read_byte(self) -> int: ... def readline(self) -> bytes: ... - def resize(self, newsize: int) -> None: ... + def resize(self, newsize: int, /) -> None: ... if sys.platform != "win32": - def seek(self, pos: int, whence: Literal[0, 1, 2, 3, 4] = os.SEEK_SET) -> None: ... + def seek(self, pos: int, whence: Literal[0, 1, 2, 3, 4] = os.SEEK_SET, /) -> None: ... else: - def seek(self, pos: int, whence: Literal[0, 1, 2] = os.SEEK_SET) -> None: ... + def seek(self, pos: int, whence: Literal[0, 1, 2] = os.SEEK_SET, /) -> None: ... def size(self) -> int: ... def tell(self) -> int: ... - def write_byte(self, byte: int) -> None: ... + def write_byte(self, byte: int, /) -> None: ... def __len__(self) -> int: ... closed: bool if sys.platform != "win32": - def madvise(self, option: int, start: int = 0, length: int = ...) -> None: ... + def madvise(self, option: int, start: int = 0, length: int = ..., /) -> None: ... - def find(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... - def rfind(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... - def read(self, n: int | None = None) -> bytes: ... - def write(self, bytes: ReadableBuffer) -> int: ... + def find(self, view: ReadableBuffer, start: int = ..., end: int = ..., /) -> int: ... + def rfind(self, view: ReadableBuffer, start: int = ..., end: int = ..., /) -> int: ... + def read(self, n: int | None = None, /) -> bytes: ... + def write(self, bytes: ReadableBuffer, /) -> int: ... @overload def __getitem__(self, key: int, /) -> int: ... @overload @@ -92,7 +92,7 @@ class mmap: # so we claim that there is also an __iter__ to help type checkers. def __iter__(self) -> Iterator[int]: ... def __enter__(self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... + def __exit__(self, exc_type: Unused, exc_value: Unused, traceback: Unused, /) -> None: ... def __buffer__(self, flags: int, /) -> memoryview: ... def __release_buffer__(self, buffer: memoryview, /) -> None: ... if sys.version_info >= (3, 13): diff --git a/mypy/typeshed/stdlib/multiprocessing/dummy/__init__.pyi b/mypy/typeshed/stdlib/multiprocessing/dummy/__init__.pyi index 3cbeeb057791..62fef2b080f2 100644 --- a/mypy/typeshed/stdlib/multiprocessing/dummy/__init__.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/dummy/__init__.pyi @@ -1,4 +1,5 @@ import array +import sys import threading import weakref from collections.abc import Callable, Iterable, Mapping, Sequence @@ -44,14 +45,25 @@ class DummyProcess(threading.Thread): _start_called: int @property def exitcode(self) -> Literal[0] | None: ... - def __init__( - self, - group: Any = None, - target: Callable[..., object] | None = None, - name: str | None = None, - args: Iterable[Any] = (), - kwargs: Mapping[str, Any] = {}, - ) -> None: ... + if sys.version_info >= (3, 14): + # Default changed in Python 3.14.1 + def __init__( + self, + group: Any = None, + target: Callable[..., object] | None = None, + name: str | None = None, + args: Iterable[Any] = (), + kwargs: Mapping[str, Any] | None = None, + ) -> None: ... + else: + def __init__( + self, + group: Any = None, + target: Callable[..., object] | None = None, + name: str | None = None, + args: Iterable[Any] = (), + kwargs: Mapping[str, Any] | None = {}, + ) -> None: ... Process = DummyProcess diff --git a/mypy/typeshed/stdlib/os/__init__.pyi b/mypy/typeshed/stdlib/os/__init__.pyi index bb0a57153948..b0640b5229e7 100644 --- a/mypy/typeshed/stdlib/os/__init__.pyi +++ b/mypy/typeshed/stdlib/os/__init__.pyi @@ -174,7 +174,8 @@ __all__ = [ "write", ] if sys.version_info >= (3, 14): - __all__ += ["readinto"] + # reload_environ was added to __all__ in Python 3.14.1 + __all__ += ["readinto", "reload_environ"] if sys.platform == "darwin" and sys.version_info >= (3, 12): __all__ += ["PRIO_DARWIN_BG", "PRIO_DARWIN_NONUI", "PRIO_DARWIN_PROCESS", "PRIO_DARWIN_THREAD"] if sys.platform == "darwin" and sys.version_info >= (3, 10): @@ -1476,34 +1477,66 @@ else: def WEXITSTATUS(status: int) -> int: ... def WSTOPSIG(status: int) -> int: ... def WTERMSIG(status: int) -> int: ... - def posix_spawn( - path: StrOrBytesPath, - argv: _ExecVArgs, - env: _ExecEnv, - /, - *, - file_actions: Sequence[tuple[Any, ...]] | None = ..., - setpgroup: int | None = ..., - resetids: bool = ..., - setsid: bool = ..., - setsigmask: Iterable[int] = ..., - setsigdef: Iterable[int] = ..., - scheduler: tuple[Any, sched_param] | None = ..., - ) -> int: ... - def posix_spawnp( - path: StrOrBytesPath, - argv: _ExecVArgs, - env: _ExecEnv, - /, - *, - file_actions: Sequence[tuple[Any, ...]] | None = ..., - setpgroup: int | None = ..., - resetids: bool = ..., - setsid: bool = ..., - setsigmask: Iterable[int] = ..., - setsigdef: Iterable[int] = ..., - scheduler: tuple[Any, sched_param] | None = ..., - ) -> int: ... + + if sys.version_info >= (3, 13): + def posix_spawn( + path: StrOrBytesPath, + argv: _ExecVArgs, + env: _ExecEnv | None, # None allowed starting in 3.13 + /, + *, + file_actions: Sequence[tuple[Any, ...]] | None = ..., + setpgroup: int | None = ..., + resetids: bool = ..., + setsid: bool = ..., + setsigmask: Iterable[int] = ..., + setsigdef: Iterable[int] = ..., + scheduler: tuple[Any, sched_param] | None = ..., + ) -> int: ... + def posix_spawnp( + path: StrOrBytesPath, + argv: _ExecVArgs, + env: _ExecEnv | None, # None allowed starting in 3.13 + /, + *, + file_actions: Sequence[tuple[Any, ...]] | None = ..., + setpgroup: int | None = ..., + resetids: bool = ..., + setsid: bool = ..., + setsigmask: Iterable[int] = ..., + setsigdef: Iterable[int] = ..., + scheduler: tuple[Any, sched_param] | None = ..., + ) -> int: ... + else: + def posix_spawn( + path: StrOrBytesPath, + argv: _ExecVArgs, + env: _ExecEnv, + /, + *, + file_actions: Sequence[tuple[Any, ...]] | None = ..., + setpgroup: int | None = ..., + resetids: bool = ..., + setsid: bool = ..., + setsigmask: Iterable[int] = ..., + setsigdef: Iterable[int] = ..., + scheduler: tuple[Any, sched_param] | None = ..., + ) -> int: ... + def posix_spawnp( + path: StrOrBytesPath, + argv: _ExecVArgs, + env: _ExecEnv, + /, + *, + file_actions: Sequence[tuple[Any, ...]] | None = ..., + setpgroup: int | None = ..., + resetids: bool = ..., + setsid: bool = ..., + setsigmask: Iterable[int] = ..., + setsigdef: Iterable[int] = ..., + scheduler: tuple[Any, sched_param] | None = ..., + ) -> int: ... + POSIX_SPAWN_OPEN: Final = 0 POSIX_SPAWN_CLOSE: Final = 1 POSIX_SPAWN_DUP2: Final = 2 diff --git a/mypy/typeshed/stdlib/pdb.pyi b/mypy/typeshed/stdlib/pdb.pyi index 2f114b20572d..f936e94cda90 100644 --- a/mypy/typeshed/stdlib/pdb.pyi +++ b/mypy/typeshed/stdlib/pdb.pyi @@ -201,8 +201,8 @@ class Pdb(Bdb, Cmd): def completenames(self, text: str, line: str, begidx: int, endidx: int) -> list[str]: ... # type: ignore[override] if sys.version_info >= (3, 12): def set_convenience_variable(self, frame: FrameType, name: str, value: Any) -> None: ... - if sys.version_info >= (3, 13) and sys.version_info < (3, 14): - # Added in 3.13.8. + if sys.version_info >= (3, 13): + # Added in 3.13.8 and 3.14.1 @property def rlcompleter(self) -> type[Completer]: ... diff --git a/mypy/typeshed/stdlib/pyexpat/__init__.pyi b/mypy/typeshed/stdlib/pyexpat/__init__.pyi index 21e676052098..bc522d5f3c92 100644 --- a/mypy/typeshed/stdlib/pyexpat/__init__.pyi +++ b/mypy/typeshed/stdlib/pyexpat/__init__.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import ReadableBuffer, SupportsRead from collections.abc import Callable from pyexpat import errors as errors, model as model @@ -29,6 +30,11 @@ class XMLParserType: def UseForeignDTD(self, flag: bool = True, /) -> None: ... def GetReparseDeferralEnabled(self) -> bool: ... def SetReparseDeferralEnabled(self, enabled: bool, /) -> None: ... + if sys.version_info >= (3, 10): + # Added in Python 3.10.20, 3.11.15, 3.12.3, 3.13.10, 3.14.1 + def SetAllocTrackerActivationThreshold(self, threshold: int, /) -> None: ... + def SetAllocTrackerMaximumAmplification(self, max_factor: float, /) -> None: ... + @property def intern(self) -> dict[str, str]: ... buffer_size: int diff --git a/mypy/typeshed/stdlib/socket.pyi b/mypy/typeshed/stdlib/socket.pyi index b10b3560b91f..92bf48c3a2d8 100644 --- a/mypy/typeshed/stdlib/socket.pyi +++ b/mypy/typeshed/stdlib/socket.pyi @@ -969,6 +969,21 @@ if sys.platform != "linux": if sys.platform != "darwin" and sys.platform != "linux": __all__ += ["AF_BLUETOOTH"] +if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux": + from _socket import BTPROTO_HCI as BTPROTO_HCI, BTPROTO_L2CAP as BTPROTO_L2CAP, BTPROTO_SCO as BTPROTO_SCO + + __all__ += ["BTPROTO_HCI", "BTPROTO_L2CAP", "BTPROTO_SCO"] + +if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux": + from _socket import HCI_DATA_DIR as HCI_DATA_DIR, HCI_FILTER as HCI_FILTER, HCI_TIME_STAMP as HCI_TIME_STAMP + + __all__ += ["HCI_FILTER", "HCI_TIME_STAMP", "HCI_DATA_DIR"] + +if sys.version_info >= (3, 11) and sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin": + from _socket import LOCAL_CREDS as LOCAL_CREDS, LOCAL_CREDS_PERSISTENT as LOCAL_CREDS_PERSISTENT, SCM_CREDS2 as SCM_CREDS2 + + __all__ += ["SCM_CREDS2", "LOCAL_CREDS", "LOCAL_CREDS_PERSISTENT"] + if sys.platform == "win32" and sys.version_info >= (3, 12): __all__ += ["AF_HYPERV"] diff --git a/mypy/typeshed/stdlib/tarfile.pyi b/mypy/typeshed/stdlib/tarfile.pyi index f6623ea9929d..4ef096be330e 100644 --- a/mypy/typeshed/stdlib/tarfile.pyi +++ b/mypy/typeshed/stdlib/tarfile.pyi @@ -214,7 +214,7 @@ class TarFile: errorlevel: int | None = ..., level: None = None, options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, ) -> Self: ... @overload @@ -355,7 +355,7 @@ class TarFile: debug: int | None = ..., errorlevel: int | None = ..., options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, ) -> Self: ... @overload @classmethod @@ -376,7 +376,7 @@ class TarFile: debug: int | None = ..., errorlevel: int | None = ..., options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, ) -> Self: ... @overload @@ -611,7 +611,7 @@ class TarFile: fileobj: IO[bytes] | None = None, level: None = None, options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, *, format: int | None = ..., tarinfo: type[TarInfo] | None = ..., @@ -631,7 +631,7 @@ class TarFile: fileobj: IO[bytes] | None = None, level: int | None = None, options: Mapping[int, int] | None = None, - zstd_dict: ZstdDict | None = None, + zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, *, format: int | None = ..., tarinfo: type[TarInfo] | None = ..., diff --git a/mypy/typeshed/stdlib/typing.pyi b/mypy/typeshed/stdlib/typing.pyi index 3c3bf30f83b7..8b36ff7b1a92 100644 --- a/mypy/typeshed/stdlib/typing.pyi +++ b/mypy/typeshed/stdlib/typing.pyi @@ -762,6 +762,11 @@ class ValuesView(MappingView, Collection[_VT_co]): def __contains__(self, value: object) -> bool: ... def __iter__(self) -> Iterator[_VT_co]: ... +# note for Mapping.get and MutableMapping.pop and MutableMapping.setdefault +# In _collections_abc.py the parameters are positional-or-keyword, +# but dict and types.MappingProxyType (the vast majority of Mapping types) +# don't allow keyword arguments. + class Mapping(Collection[_KT], Generic[_KT, _VT_co]): # TODO: We wish the key type could also be covariant, but that doesn't work, # see discussion in https://github.com/python/typing/pull/273. @@ -771,9 +776,9 @@ class Mapping(Collection[_KT], Generic[_KT, _VT_co]): @overload def get(self, key: _KT, /) -> _VT_co | None: ... @overload - def get(self, key: _KT, /, default: _VT_co) -> _VT_co: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter + def get(self, key: _KT, default: _VT_co, /) -> _VT_co: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter @overload - def get(self, key: _KT, /, default: _T) -> _VT_co | _T: ... + def get(self, key: _KT, default: _T, /) -> _VT_co | _T: ... def items(self) -> ItemsView[_KT, _VT_co]: ... def keys(self) -> KeysView[_KT]: ... def values(self) -> ValuesView[_VT_co]: ... @@ -789,9 +794,9 @@ class MutableMapping(Mapping[_KT, _VT]): @overload def pop(self, key: _KT, /) -> _VT: ... @overload - def pop(self, key: _KT, /, default: _VT) -> _VT: ... + def pop(self, key: _KT, default: _VT, /) -> _VT: ... @overload - def pop(self, key: _KT, /, default: _T) -> _VT | _T: ... + def pop(self, key: _KT, default: _T, /) -> _VT | _T: ... def popitem(self) -> tuple[_KT, _VT]: ... # This overload should be allowed only if the value type is compatible with None. # diff --git a/test-data/unit/pythoneval.test b/test-data/unit/pythoneval.test index fb8c7cb1555b..9f057042926d 100644 --- a/test-data/unit/pythoneval.test +++ b/test-data/unit/pythoneval.test @@ -1059,8 +1059,8 @@ _testTypedDictGet.py:10: note: Revealed type is "builtins.object" _testTypedDictGet.py:11: error: All overload variants of "get" of "Mapping" require at least one argument _testTypedDictGet.py:11: note: Possible overload variants: _testTypedDictGet.py:11: note: def get(self, str, /) -> object -_testTypedDictGet.py:11: note: def get(self, str, /, default: object) -> object -_testTypedDictGet.py:11: note: def [_T] get(self, str, /, default: _T) -> object +_testTypedDictGet.py:11: note: def get(self, str, object, /) -> object +_testTypedDictGet.py:11: note: def [_T] get(self, str, _T, /) -> object _testTypedDictGet.py:13: note: Revealed type is "builtins.object" _testTypedDictGet.py:16: note: Revealed type is "builtins.int | None" _testTypedDictGet.py:17: note: Revealed type is "builtins.str | None" @@ -1068,8 +1068,8 @@ _testTypedDictGet.py:18: note: Revealed type is "builtins.object" _testTypedDictGet.py:19: error: All overload variants of "get" of "Mapping" require at least one argument _testTypedDictGet.py:19: note: Possible overload variants: _testTypedDictGet.py:19: note: def get(self, str, /) -> object -_testTypedDictGet.py:19: note: def get(self, str, /, default: object) -> object -_testTypedDictGet.py:19: note: def [_T] get(self, str, /, default: _T) -> object +_testTypedDictGet.py:19: note: def get(self, str, object, /) -> object +_testTypedDictGet.py:19: note: def [_T] get(self, str, _T, /) -> object _testTypedDictGet.py:21: note: Revealed type is "builtins.object" [case testTypedDictMappingMethods]