Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mypy/typeshed/stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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: ...
Expand Down
9 changes: 9 additions & 0 deletions mypy/typeshed/stdlib/_winapi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand All @@ -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: ...
Expand Down Expand Up @@ -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: ...
9 changes: 7 additions & 2 deletions mypy/typeshed/stdlib/_zstd.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: ...
Expand Down
6 changes: 5 additions & 1 deletion mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
30 changes: 22 additions & 8 deletions mypy/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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: ...

Expand Down
9 changes: 7 additions & 2 deletions mypy/typeshed/stdlib/compression/zstd/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions mypy/typeshed/stdlib/compression/zstd/_zstdfile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand All @@ -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]
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions mypy/typeshed/stdlib/heapq.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import sys
from _heapq import *
from _typeshed import SupportsRichComparison
from collections.abc import Callable, Generator, Iterable
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]
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/importlib/readers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Expand Down
5 changes: 3 additions & 2 deletions mypy/typeshed/stdlib/importlib/resources/abc.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from _typeshed import StrPath
from abc import ABCMeta, abstractmethod
from collections.abc import Iterator
from io import BufferedReader
Expand All @@ -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,
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion mypy/typeshed/stdlib/importlib/resources/simple.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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: ...
24 changes: 12 additions & 12 deletions mypy/typeshed/stdlib/mmap.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
28 changes: 20 additions & 8 deletions mypy/typeshed/stdlib/multiprocessing/dummy/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import array
import sys
import threading
import weakref
from collections.abc import Callable, Iterable, Mapping, Sequence
Expand Down Expand Up @@ -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

Expand Down
Loading