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
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From 5c922a2484f2e18c7f901e62bb499b6414cf1090 Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Wed, 18 Feb 2026 13:11:02 +0100
Subject: [PATCH] Adjust stubs to fix mypy lookup error due to circular
dependencies in stubs

---
mypy/typeshed/stdlib/time.pyi | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mypy/typeshed/stdlib/time.pyi b/mypy/typeshed/stdlib/time.pyi
index 64a009318..d0853792b 100644
--- a/mypy/typeshed/stdlib/time.pyi
+++ b/mypy/typeshed/stdlib/time.pyi
@@ -1,16 +1,16 @@
import sys
from _typeshed import structseq
-from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, final, type_check_only
+from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, Union, final, type_check_only
from typing_extensions import TypeAlias

_TimeTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int]

if sys.version_info >= (3, 15):
# anticipate on https://github.com/python/cpython/pull/139224
- _SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex
+ _SupportsFloatOrIndex: TypeAlias = Union[SupportsFloat, SupportsIndex]
else:
# before, time functions only accept (subclass of) float, *not* SupportsFloat
- _SupportsFloatOrIndex: TypeAlias = float | SupportsIndex
+ _SupportsFloatOrIndex: TypeAlias = Union[float, SupportsIndex]

altzone: int
daylight: int
--
2.53.0

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
From ed11d7e0204868ef1a43c17ed950372b1d78f497 Mon Sep 17 00:00:00 2001
From b3021cdc4b4c2cf547c5bc2d1d21a5a00ffea001 Mon Sep 17 00:00:00 2001
From: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Date: Mon, 26 Sep 2022 12:55:07 -0700
Subject: [PATCH] Remove use of LiteralString in builtins (#13743)

---
mypy/typeshed/stdlib/builtins.pyi | 100 +-----------------------------
1 file changed, 1 insertion(+), 99 deletions(-)
mypy/typeshed/stdlib/builtins.pyi | 98 -------------------------------
1 file changed, 98 deletions(-)

diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
index 693dd0b77..8acdeadff 100644
index efc51fe25..8600a372b 100644
--- a/mypy/typeshed/stdlib/builtins.pyi
+++ b/mypy/typeshed/stdlib/builtins.pyi
@@ -64,7 +64,6 @@ from typing import ( # noqa: Y022,UP035
Expand Down Expand Up @@ -163,10 +163,9 @@ index 693dd0b77..8acdeadff 100644
def __eq__(self, value: object, /) -> bool: ...
def __ge__(self, value: str, /) -> bool: ...
- @overload
- def __getitem__(self: LiteralString, key: SupportsIndex | slice, /) -> LiteralString: ...
- def __getitem__(self: LiteralString, key: SupportsIndex | slice[SupportsIndex | None], /) -> LiteralString: ...
- @overload
- def __getitem__(self, key: SupportsIndex | slice, /) -> str: ... # type: ignore[misc]
+ def __getitem__(self, key: SupportsIndex | slice, /) -> str: ...
def __getitem__(self, key: SupportsIndex | slice[SupportsIndex | None], /) -> str: ... # type: ignore[misc]
def __gt__(self, value: str, /) -> bool: ...
def __hash__(self) -> int: ...
- @overload
Expand Down
4 changes: 1 addition & 3 deletions mypy/server/aststrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ def visit_class_def(self, node: ClassDef) -> None:
node.type_vars = []
node.base_type_exprs.extend(node.removed_base_type_exprs)
node.removed_base_type_exprs = []
node.defs.body = [
s for s in node.defs.body if s not in to_delete # type: ignore[comparison-overlap]
]
node.defs.body = [s for s in node.defs.body if s not in to_delete]
with self.enter_class(node.info):
super().visit_class_def(node)
node.defs.body.extend(node.removed_statements)
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ py_compile: 3.0-
pyclbr: 3.0-
pydoc: 3.0-
pydoc_data: 3.0-
pydoc_data.module_docs: 3.13-
pyexpat: 3.0-
queue: 3.0-
quopri: 3.0-
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from abc import abstractmethod
from types import MappingProxyType
from typing import ( # noqa: Y022,Y038,UP035,Y057
from typing import ( # noqa: Y022,Y038,UP035,Y057,RUF100
AbstractSet as Set,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
Expand Down
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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, Literal, TypeVar, final, overload, type_check_only
from typing import Any, ClassVar, Final, Generic, Literal, SupportsIndex, TypeVar, final, overload, type_check_only
from typing_extensions import Self, TypeAlias

_T = TypeVar("_T")
Expand Down Expand Up @@ -134,7 +134,7 @@ class _Pointer(_PointerLike, _CData, Generic[_CT], metaclass=_PyCPointerType):
@overload
def __getitem__(self, key: int, /) -> Any: ...
@overload
def __getitem__(self, key: slice, /) -> list[Any]: ...
def __getitem__(self, key: slice[SupportsIndex | None], /) -> list[Any]: ...
def __setitem__(self, key: int, value: Any, /) -> None: ...

if sys.version_info < (3, 14):
Expand Down Expand Up @@ -338,11 +338,11 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
@overload
def __getitem__(self, key: int, /) -> Any: ...
@overload
def __getitem__(self, key: slice, /) -> list[Any]: ...
def __getitem__(self, key: slice[SupportsIndex | None], /) -> list[Any]: ...
@overload
def __setitem__(self, key: int, value: Any, /) -> None: ...
@overload
def __setitem__(self, key: slice, value: Iterable[Any], /) -> None: ...
def __setitem__(self, key: slice[SupportsIndex | None], value: Iterable[Any], /) -> None: ...
def __iter__(self) -> Iterator[Any]: ...
# Can't inherit from Sized because the metaclass conflict between
# Sized and _CData prevents using _CDataMeta.
Expand Down
10 changes: 5 additions & 5 deletions mypy/typeshed/stdlib/_operator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,20 @@ 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: ...
@overload
def delitem(a: MutableSequence[Any], b: SupportsIndex, /) -> None: ...
def delitem(a: MutableSequence[Any], b: int, /) -> None: ...
@overload
def delitem(a: MutableSequence[Any], b: slice, /) -> None: ...
def delitem(a: MutableSequence[Any], b: slice[int | None], /) -> None: ...
@overload
def delitem(a: MutableMapping[_K, Any], b: _K, /) -> None: ...
@overload
def getitem(a: Sequence[_T], b: slice, /) -> Sequence[_T]: ...
def getitem(a: Sequence[_T], b: slice[int | None], /) -> Sequence[_T]: ...
@overload
def getitem(a: SupportsGetItem[_K, _V], b: _K, /) -> _V: ...
def indexOf(a: Iterable[_T], b: _T, /) -> int: ...
@overload
def setitem(a: MutableSequence[_T], b: SupportsIndex, c: _T, /) -> None: ...
def setitem(a: MutableSequence[_T], b: int, c: _T, /) -> None: ...
@overload
def setitem(a: MutableSequence[_T], b: slice, c: Sequence[_T], /) -> None: ...
def setitem(a: MutableSequence[_T], b: slice[int | None], c: Sequence[_T], /) -> None: ...
@overload
def setitem(a: MutableMapping[_K, _V], b: _K, c: _V, /) -> None: ...
def length_hint(obj: object, default: int = 0, /) -> int: ...
Expand Down
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/_socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ if sys.platform != "linux":

has_ipv6: bool

if sys.platform != "darwin" and sys.platform != "linux":
if sys.platform != "darwin":
BDADDR_ANY: Final = "00:00:00:00:00:00"
BDADDR_LOCAL: Final = "00:00:00:FF:FF:FF"

Expand Down Expand Up @@ -660,16 +660,16 @@ if sys.platform == "darwin":
PF_SYSTEM: Final[int]
SYSPROTO_CONTROL: Final[int]

if sys.platform != "darwin" and sys.platform != "linux":
if sys.platform != "darwin":
AF_BLUETOOTH: Final[int]

if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
if sys.platform != "win32" and sys.platform != "darwin":
# Linux and some BSD support is explicit in the docs
# Windows and macOS do not support in practice
BTPROTO_HCI: Final[int]
BTPROTO_L2CAP: Final[int]
BTPROTO_SCO: Final[int] # not in FreeBSD
if sys.platform != "darwin" and sys.platform != "linux":
if sys.platform != "darwin":
BTPROTO_RFCOMM: Final[int]

if sys.platform == "linux":
Expand Down
34 changes: 21 additions & 13 deletions mypy/typeshed/stdlib/_thread.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from collections.abc import Callable
from threading import Thread
from types import TracebackType
from typing import Any, Final, NoReturn, final, overload
from typing_extensions import TypeVarTuple, Unpack, disjoint_base
from typing_extensions import TypeVarTuple, Unpack, deprecated, disjoint_base

_Ts = TypeVarTuple("_Ts")

Expand Down Expand Up @@ -38,9 +38,12 @@ if sys.version_info >= (3, 13):
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
def release(self) -> None: ...
def locked(self) -> bool: ...
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ...
def release_lock(self) -> None: ...
def locked_lock(self) -> bool: ...
@deprecated("Obsolete synonym. Use `acquire()` instead.")
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ... # undocumented
@deprecated("Obsolete synonym. Use `release()` instead.")
def release_lock(self) -> None: ... # undocumented
@deprecated("Obsolete synonym. Use `locked()` instead.")
def locked_lock(self) -> bool: ... # undocumented
def __enter__(self) -> bool: ...
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
Expand All @@ -53,9 +56,12 @@ else:
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
def release(self) -> None: ...
def locked(self) -> bool: ...
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ...
def release_lock(self) -> None: ...
def locked_lock(self) -> bool: ...
@deprecated("Obsolete synonym. Use `acquire()` instead.")
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ... # undocumented
@deprecated("Obsolete synonym. Use `release()` instead.")
def release_lock(self) -> None: ... # undocumented
@deprecated("Obsolete synonym. Use `locked()` instead.")
def locked_lock(self) -> bool: ... # undocumented
def __enter__(self) -> bool: ...
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
Expand All @@ -65,12 +71,12 @@ else:
def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ...
@overload
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...

# Obsolete synonym for start_new_thread()
@overload
def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ...
@deprecated("Obsolete synonym. Use `start_new_thread()` instead.")
def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ... # undocumented
@overload
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...
@deprecated("Obsolete synonym. Use `start_new_thread()` instead.")
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ... # undocumented

if sys.version_info >= (3, 10):
def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ...
Expand All @@ -79,9 +85,11 @@ else:
def interrupt_main() -> None: ...

def exit() -> NoReturn: ...
def exit_thread() -> NoReturn: ... # Obsolete synonym for exit()
@deprecated("Obsolete synonym. Use `exit()` instead.")
def exit_thread() -> NoReturn: ... # undocumented
def allocate_lock() -> LockType: ...
def allocate() -> LockType: ... # Obsolete synonym for allocate_lock()
@deprecated("Obsolete synonym. Use `allocate_lock()` instead.")
def allocate() -> LockType: ... # undocumented
def get_ident() -> int: ...
def stack_size(size: int = 0, /) -> int: ...

Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_typeshed/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Utility types for typeshed

This package and its submodules contains various common types used by
This package and its submodules contain various common types used by
typeshed. It can also be used by packages outside typeshed, but beware
the API stability guarantees below.

Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ WriteableBuffer: TypeAlias = Buffer
ReadableBuffer: TypeAlias = Buffer # stable

class SliceableBuffer(Buffer, Protocol):
def __getitem__(self, slice: slice, /) -> Sequence[int]: ...
def __getitem__(self, slice: slice[SupportsIndex | None], /) -> Sequence[int]: ...

class IndexableBuffer(Buffer, Protocol):
def __getitem__(self, i: int, /) -> int: ...

class SupportsGetItemBuffer(SliceableBuffer, IndexableBuffer, Protocol):
def __contains__(self, x: Any, /) -> bool: ...
@overload
def __getitem__(self, slice: slice, /) -> Sequence[int]: ...
def __getitem__(self, slice: slice[SupportsIndex | None], /) -> Sequence[int]: ...
@overload
def __getitem__(self, i: int, /) -> int: ...

Expand Down
5 changes: 4 additions & 1 deletion mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ class HelpFormatter:
def _format_usage(
self, usage: str | None, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup], prefix: str | None
) -> str: ...
def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup]) -> str: ...
if sys.version_info < (3, 14):
# Removed in Python 3.14.3
def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup]) -> str: ...

def _format_text(self, text: str) -> str: ...
def _format_action(self, action: Action) -> str: ...
def _format_action_invocation(self, action: Action) -> str: ...
Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ class array(MutableSequence[_T]):
@overload
def __getitem__(self, key: SupportsIndex, /) -> _T: ...
@overload
def __getitem__(self, key: slice, /) -> array[_T]: ...
def __getitem__(self, key: slice[SupportsIndex | None], /) -> array[_T]: ...
@overload # type: ignore[override]
def __setitem__(self, key: SupportsIndex, value: _T, /) -> None: ...
@overload
def __setitem__(self, key: slice, value: array[_T], /) -> None: ...
def __delitem__(self, key: SupportsIndex | slice, /) -> None: ...
def __setitem__(self, key: slice[SupportsIndex | None], value: array[_T], /) -> None: ...
def __delitem__(self, key: SupportsIndex | slice[SupportsIndex | None], /) -> None: ...
def __add__(self, value: array[_T], /) -> array[_T]: ...
def __eq__(self, value: object, /) -> bool: ...
def __ge__(self, value: array[_T], /) -> bool: ...
Expand Down
Loading