Skip to content
Open
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
5 changes: 4 additions & 1 deletion mypy/typeshed/stdlib/_pickle.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class PicklerMemoProxy:
class Pickler:
fast: bool
dispatch_table: Mapping[type, Callable[[Any], _ReducedType]]
reducer_override: Callable[[Any], Any]
bin: bool # undocumented
def __init__(
self,
Expand All @@ -79,6 +78,10 @@ class Pickler:

# this method has no default implementation for Python < 3.13
def persistent_id(self, obj: Any, /) -> Any: ...
# The following method is not defined on _Pickler, but can be defined on
# sub-classes. Should return `NotImplemented` if pickling the supplied
# object is not supported and returns the same types as `__reduce__()`.
def reducer_override(self, obj: object, /) -> _ReducedType: ...

@type_check_only
class UnpicklerMemoProxy:
Expand Down
10 changes: 7 additions & 3 deletions mypy/typeshed/stdlib/_sqlite3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ from sqlite3 import (
_IsolationLevel,
)
from typing import Any, Final, Literal, TypeVar, overload
from typing_extensions import TypeAlias
from typing_extensions import TypeAlias, deprecated

if sys.version_info >= (3, 11):
from sqlite3 import Blob as Blob
Expand Down Expand Up @@ -299,7 +299,11 @@ def enable_callback_tracebacks(enable: bool, /) -> None: ...

if sys.version_info < (3, 12):
# takes a pos-or-keyword argument because there is a C wrapper
def enable_shared_cache(do_enable: int) -> None: ...
@deprecated(
"Deprecated since Python 3.10; removed in Python 3.12. "
"Open database in URI mode using `cache=shared` parameter instead."
)
def enable_shared_cache(do_enable: int) -> None: ... # undocumented

if sys.version_info >= (3, 10):
def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ...
Expand All @@ -310,4 +314,4 @@ else:
def register_converter(name: str, converter: _Converter, /) -> None: ...

if sys.version_info < (3, 10):
OptimizedUnicode = str
OptimizedUnicode = str # undocumented
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/_ssl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ if sys.version_info < (3, 12):
def RAND_pseudo_bytes(n: int, /) -> tuple[bytes, bool]: ...

if sys.version_info < (3, 10):
@deprecated("Unsupported by OpenSSL since 1.1.1; removed in Python 3.10.")
def RAND_egd(path: str) -> None: ...

def RAND_status() -> bool: ...
Expand Down
16 changes: 12 additions & 4 deletions mypy/typeshed/stdlib/asyncio/base_tasks.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import sys
from _typeshed import StrOrBytesPath
from types import FrameType
from typing import Any

from . import tasks
from .tasks import Task

def _task_repr_info(task: tasks.Task[Any]) -> list[str]: ... # undocumented
def _task_get_stack(task: tasks.Task[Any], limit: int | None) -> list[FrameType]: ... # undocumented
def _task_print_stack(task: tasks.Task[Any], limit: int | None, file: StrOrBytesPath) -> None: ... # undocumented
def _task_repr_info(task: Task[Any]) -> list[str]: ... # undocumented

if sys.version_info >= (3, 13):
def _task_repr(task: Task[Any]) -> str: ... # undocumented

elif sys.version_info >= (3, 11):
def _task_repr(self: Task[Any]) -> str: ... # undocumented

def _task_get_stack(task: Task[Any], limit: int | None) -> list[FrameType]: ... # undocumented
def _task_print_stack(task: Task[Any], limit: int | None, file: StrOrBytesPath) -> None: ... # undocumented
80 changes: 54 additions & 26 deletions mypy/typeshed/stdlib/asyncio/unix_events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,35 @@ if sys.platform != "win32":
def remove_child_handler(self, pid: int) -> bool: ...
def attach_loop(self, loop: events.AbstractEventLoop | None) -> None: ...

@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
class ThreadedChildWatcher(AbstractChildWatcher):
def is_active(self) -> Literal[True]: ...
def close(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
def __del__(self) -> None: ...
def add_child_handler(
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
def attach_loop(self, loop: events.AbstractEventLoop | None) -> None: ...

@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
class PidfdChildWatcher(AbstractChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
def is_active(self) -> bool: ...
def close(self) -> None: ...
def attach_loop(self, loop: events.AbstractEventLoop | None) -> None: ...
def add_child_handler(
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...

else:
class MultiLoopChildWatcher(AbstractChildWatcher):
def is_active(self) -> bool: ...
Expand All @@ -219,30 +248,29 @@ if sys.platform != "win32":
def remove_child_handler(self, pid: int) -> bool: ...
def attach_loop(self, loop: events.AbstractEventLoop | None) -> None: ...

if sys.version_info < (3, 14):
class ThreadedChildWatcher(AbstractChildWatcher):
def is_active(self) -> Literal[True]: ...
def close(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
def __del__(self) -> None: ...
def add_child_handler(
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
def attach_loop(self, loop: events.AbstractEventLoop | None) -> None: ...
class ThreadedChildWatcher(AbstractChildWatcher):
def is_active(self) -> Literal[True]: ...
def close(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
def __del__(self) -> None: ...
def add_child_handler(
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
def attach_loop(self, loop: events.AbstractEventLoop | None) -> None: ...

class PidfdChildWatcher(AbstractChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
def is_active(self) -> bool: ...
def close(self) -> None: ...
def attach_loop(self, loop: events.AbstractEventLoop | None) -> None: ...
def add_child_handler(
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
class PidfdChildWatcher(AbstractChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
def is_active(self) -> bool: ...
def close(self) -> None: ...
def attach_loop(self, loop: events.AbstractEventLoop | None) -> None: ...
def add_child_handler(
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/code.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class InteractiveConsole(InteractiveInterpreter):
buffer: list[str] # undocumented
filename: str # undocumented
if sys.version_info >= (3, 13):
local_exit: bool # undocumented
def __init__(
self, locals: dict[str, Any] | None = None, filename: str = "<console>", *, local_exit: bool = False
) -> None: ...
Expand Down
13 changes: 10 additions & 3 deletions mypy/typeshed/stdlib/configparser.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
from _typeshed import MaybeNone, StrOrBytesPath, SupportsWrite
from _typeshed import BytesPath, GenericPath, MaybeNone, StrOrBytesPath, StrPath, SupportsWrite
from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence
from re import Pattern
from typing import Any, ClassVar, Final, Literal, TypeVar, overload, type_check_only
from typing import Any, AnyStr, ClassVar, Final, Literal, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias, deprecated

if sys.version_info >= (3, 14):
Expand Down Expand Up @@ -269,7 +269,14 @@ class RawConfigParser(_Parser):
def has_section(self, section: _SectionName) -> bool: ...
def options(self, section: _SectionName) -> list[str]: ...
def has_option(self, section: _SectionName, option: str) -> bool: ...
def read(self, filenames: StrOrBytesPath | Iterable[StrOrBytesPath], encoding: str | None = None) -> list[str]: ...
@overload
def read(self, filenames: GenericPath[AnyStr], encoding: str | None = None) -> list[AnyStr]: ...
@overload
def read(self, filenames: Iterable[StrPath], encoding: str | None = None) -> list[str]: ...
@overload
def read(self, filenames: Iterable[BytesPath], encoding: str | None = None) -> list[bytes]: ...
@overload
def read(self, filenames: Iterable[StrOrBytesPath], encoding: str | None = None) -> list[str | bytes]: ...
def read_file(self, f: Iterable[str], source: str | None = None) -> None: ...
def read_string(self, string: str, source: str = "<string>") -> None: ...
def read_dict(self, dictionary: Mapping[str, Mapping[str, Any]], source: str = "<dict>") -> None: ...
Expand Down
3 changes: 2 additions & 1 deletion mypy/typeshed/stdlib/importlib/metadata/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from importlib.abc import MetaPathFinder
from os import PathLike
from pathlib import Path
from re import Pattern
from typing import Any, ClassVar, Generic, NamedTuple, TypeVar, overload
from typing import Any, ClassVar, Generic, NamedTuple, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias, deprecated, disjoint_base

_T = TypeVar("_T")
Expand Down Expand Up @@ -54,6 +54,7 @@ elif sys.version_info >= (3, 11):

_EntryPointBase = DeprecatedTuple
else:
@type_check_only
class _EntryPointBase(NamedTuple):
name: str
value: str
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/mmap.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PAGESIZE: Final[int]
@disjoint_base
class mmap:
if sys.platform == "win32":
def __new__(self, fileno: int, length: int, tagname: str | None = None, access: int = 0, offset: int = 0) -> Self: ...
def __new__(cls, fileno: int, length: int, tagname: str | None = None, access: int = 0, offset: int = 0) -> Self: ...
else:
if sys.version_info >= (3, 13):
def __new__(
Expand Down
5 changes: 4 additions & 1 deletion mypy/typeshed/stdlib/pickle.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ class _Pickler:
dispatch_table: Mapping[type, Callable[[Any], _ReducedType]]
bin: bool # undocumented
dispatch: ClassVar[dict[type, Callable[[Unpickler, Any], None]]] # undocumented, _Pickler only
reducer_override: Callable[[Any], Any]
def __init__(
self,
file: SupportsWrite[bytes],
Expand All @@ -220,6 +219,10 @@ class _Pickler:
def dump(self, obj: Any) -> None: ...
def clear_memo(self) -> None: ...
def persistent_id(self, obj: Any) -> Any: ...
# The following method is not defined on _Pickler, but can be defined on
# sub-classes. Should return `NotImplemented` if pickling the supplied
# object is not supported and returns the same types as `__reduce__()`.
def reducer_override(self, obj: object, /) -> _ReducedType: ...

class _Unpickler:
dispatch: ClassVar[dict[int, Callable[[Unpickler], None]]] # undocumented, _Unpickler only
Expand Down
3 changes: 2 additions & 1 deletion mypy/typeshed/stdlib/signal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ from typing_extensions import Never, TypeAlias
NSIG: int

class Signals(IntEnum):
SIGABRT = 6
SIGFPE = 8
SIGILL = 4
SIGINT = 2
SIGSEGV = 11
SIGTERM = 15

if sys.platform == "win32":
SIGABRT = 22
SIGBREAK = 21
CTRL_C_EVENT = 0
CTRL_BREAK_EVENT = 1
else:
SIGABRT = 6
SIGALRM = 14
SIGBUS = 7
SIGCHLD = 17
Expand Down
4 changes: 3 additions & 1 deletion mypy/typeshed/stdlib/statistics.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from _typeshed import SupportsRichComparisonT
from collections.abc import Callable, Hashable, Iterable, Sequence, Sized
from decimal import Decimal
from fractions import Fraction
from typing import Literal, NamedTuple, Protocol, SupportsFloat, SupportsIndex, TypeVar
from typing import Literal, NamedTuple, Protocol, SupportsFloat, SupportsIndex, TypeVar, type_check_only
from typing_extensions import Self, TypeAlias

__all__ = [
Expand Down Expand Up @@ -44,7 +44,9 @@ _Seed: TypeAlias = int | float | str | bytes | bytearray # noqa: Y041
# Used in linear_regression
_T_co = TypeVar("_T_co", covariant=True)

@type_check_only
class _SizedIterable(Iterable[_T_co], Sized, Protocol[_T_co]): ...

class StatisticsError(ValueError): ...

if sys.version_info >= (3, 11):
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/threading.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sys
from _thread import _ExceptHookArgs, get_native_id as get_native_id
from _typeshed import ProfileFunction, TraceFunction
from collections.abc import Callable, Iterable, Mapping
from contextvars import ContextVar
from contextvars import Context
from types import TracebackType
from typing import Any, Final, TypeVar, final
from typing_extensions import deprecated
Expand Down Expand Up @@ -87,7 +87,7 @@ class Thread:
kwargs: Mapping[str, Any] | None = None,
*,
daemon: bool | None = None,
context: ContextVar[Any] | None = None,
context: Context | None = None,
) -> None: ...
else:
def __init__(
Expand Down
5 changes: 5 additions & 0 deletions mypy/typeshed/stdlib/tkinter/ttk.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ _VsapiStatespec: TypeAlias = tuple[Unpack[tuple[str, ...]], int]
_P = ParamSpec("_P")
_T = TypeVar("_T")

@type_check_only
class _Layout(TypedDict, total=False):
side: Literal["left", "right", "top", "bottom"]
sticky: str # consists of letters 'n', 's', 'w', 'e', may contain repeats, may be empty
Expand All @@ -68,6 +69,7 @@ class _Layout(TypedDict, total=False):
_LayoutSpec: TypeAlias = list[tuple[str, _Layout | None]]

# Keep these in sync with the appropriate methods in Style
@type_check_only
class _ElementCreateImageKwargs(TypedDict, total=False):
border: _Padding
height: float | str
Expand All @@ -82,12 +84,15 @@ _ElementCreateArgsCrossPlatform: TypeAlias = (
| tuple[Literal["from"], str] # (fromelement is optional)
)
if sys.platform == "win32" and sys.version_info >= (3, 13):
@type_check_only
class _ElementCreateVsapiKwargsPadding(TypedDict, total=False):
padding: _Padding

@type_check_only
class _ElementCreateVsapiKwargsMargin(TypedDict, total=False):
padding: _Padding

@type_check_only
class _ElementCreateVsapiKwargsSize(TypedDict):
width: float | str
height: float | str
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/unittest/main.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class _TestRunner(Protocol):
# not really documented
class TestProgram:
result: unittest.result.TestResult
module: None | str | ModuleType
module: ModuleType | None
verbosity: int
failfast: bool | None
catchbreak: bool | None
Expand All @@ -30,7 +30,7 @@ class TestProgram:
durations: unittest.result._DurationsType | None
def __init__(
self,
module: None | str | ModuleType = "__main__",
module: ModuleType | str | None = "__main__",
defaultTest: str | Iterable[str] | None = None,
argv: list[str] | None = None,
testRunner: type[_TestRunner] | _TestRunner | None = None,
Expand Down
Loading