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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,23 +1,86 @@
From 5c922a2484f2e18c7f901e62bb499b6414cf1090 Mon Sep 17 00:00:00 2001
From 8985351bf6f917db1a7b15ffed95ec2357d9819d 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
Date: Mon, 18 May 2026 17:33:09 +0200
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(-)
mypy/typeshed/stdlib/__future__.pyi | 2 +-
mypy/typeshed/stdlib/dis.pyi | 4 ++--
mypy/typeshed/stdlib/inspect.pyi | 4 ++--
mypy/typeshed/stdlib/itertools.pyi | 2 +-
mypy/typeshed/stdlib/time.pyi | 6 +++---
5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/mypy/typeshed/stdlib/__future__.pyi b/mypy/typeshed/stdlib/__future__.pyi
index aa445d22b..a90cf1edd 100644
--- a/mypy/typeshed/stdlib/__future__.pyi
+++ b/mypy/typeshed/stdlib/__future__.pyi
@@ -1,4 +1,4 @@
-from typing import TypeAlias
+from typing_extensions import TypeAlias

_VersionInfo: TypeAlias = tuple[int, int, int, str, int]

diff --git a/mypy/typeshed/stdlib/dis.pyi b/mypy/typeshed/stdlib/dis.pyi
index 984f932e3..0ad928934 100644
--- a/mypy/typeshed/stdlib/dis.pyi
+++ b/mypy/typeshed/stdlib/dis.pyi
@@ -2,7 +2,7 @@ import sys
import types
from collections.abc import Callable, Iterator
from opcode import * # `dis` re-exports it as a part of public API
-from typing import IO, Any, Final, NamedTuple, TypeAlias, overload
+from typing import IO, Any, Final, NamedTuple, overload
from typing_extensions import Self, deprecated, disjoint_base

__all__ = [
@@ -41,7 +41,7 @@ else:

# Strictly this should not have to include Callable, but mypy doesn't use FunctionType
# for functions (python/mypy#3171)
-_HaveCodeType: TypeAlias = types.MethodType | types.FunctionType | types.CodeType | type | Callable[..., Any]
+_HaveCodeType = types.MethodType | types.FunctionType | types.CodeType | type | Callable[..., Any]

if sys.version_info >= (3, 11):
class Positions(NamedTuple):
diff --git a/mypy/typeshed/stdlib/inspect.pyi b/mypy/typeshed/stdlib/inspect.pyi
index cc39a7c9f..0ca4cff75 100644
--- a/mypy/typeshed/stdlib/inspect.pyi
+++ b/mypy/typeshed/stdlib/inspect.pyi
@@ -196,8 +196,8 @@ if sys.version_info >= (3, 14):

modulesbyfile: dict[str, Any]

-_GetMembersPredicateTypeGuard: TypeAlias = Callable[[Any], TypeGuard[_T]]
-_GetMembersPredicateTypeIs: TypeAlias = Callable[[Any], TypeIs[_T]]
+_GetMembersPredicateTypeGuard = Callable[[Any], TypeGuard[_T]]
+_GetMembersPredicateTypeIs = Callable[[Any], TypeIs[_T]]
_GetMembersPredicate: TypeAlias = Callable[[Any], bool]
_GetMembersReturn: TypeAlias = list[tuple[str, _T]]

diff --git a/mypy/typeshed/stdlib/itertools.pyi b/mypy/typeshed/stdlib/itertools.pyi
index d26a4e1da..60e79bc2e 100644
--- a/mypy/typeshed/stdlib/itertools.pyi
+++ b/mypy/typeshed/stdlib/itertools.pyi
@@ -23,7 +23,7 @@ _T10 = TypeVar("_T10")

_Step: TypeAlias = SupportsFloat | SupportsInt | SupportsIndex | SupportsComplex

-_Predicate: TypeAlias = Callable[[_T], object]
+_Predicate = Callable[[_T], object]

# Technically count can take anything that implements a number protocol and has an add method
# but we can't enforce the add method
diff --git a/mypy/typeshed/stdlib/time.pyi b/mypy/typeshed/stdlib/time.pyi
index 64a009318..d0853792b 100644
index ac53089b8..9b5344b32 100644
--- a/mypy/typeshed/stdlib/time.pyi
+++ b/mypy/typeshed/stdlib/time.pyi
@@ -1,16 +1,16 @@
@@ -1,15 +1,15 @@
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
-from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeAlias, final, type_check_only
+from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeAlias, Union, final, type_check_only

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

Expand All @@ -33,5 +96,5 @@ index 64a009318..d0853792b 100644
altzone: int
daylight: int
--
2.53.0
2.54.0

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From b6d495c10e79fb56ff64f8fb90c87894090f9cbe Mon Sep 17 00:00:00 2001
From 3fa6658041d3ccd7f2a4bd725e21fa9768bf6ebc Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Sat, 15 Feb 2025 20:11:06 +0100
Subject: [PATCH] Partially revert Clean up argparse hacks
Expand All @@ -8,16 +8,16 @@ Subject: [PATCH] Partially revert Clean up argparse hacks
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mypy/typeshed/stdlib/argparse.pyi b/mypy/typeshed/stdlib/argparse.pyi
index ae99eb036..c87b8f4fc 100644
index 22d330a08..fa22f842d 100644
--- a/mypy/typeshed/stdlib/argparse.pyi
+++ b/mypy/typeshed/stdlib/argparse.pyi
@@ -2,7 +2,7 @@ import sys
from _typeshed import SupportsWrite, sentinel
from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
-from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload, type_check_only
+from typing import IO, Any, ClassVar, Final, Generic, NewType, NoReturn, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias, deprecated
-from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only
+from typing import IO, Any, ClassVar, Final, Generic, NewType, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only
from typing_extensions import Self, deprecated

__all__ = [
@@ -36,7 +36,9 @@ ONE_OR_MORE: Final = "+"
Expand All @@ -41,5 +41,5 @@ index ae99eb036..c87b8f4fc 100644
default: Any = ...,
type: _ActionType = ...,
--
2.52.0
2.54.0

Original file line number Diff line number Diff line change
@@ -1,80 +1,94 @@
From b3021cdc4b4c2cf547c5bc2d1d21a5a00ffea001 Mon Sep 17 00:00:00 2001
From 83cf9b2dcc569149510c3a9118b9a7dc44144232 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 | 98 -------------------------------
1 file changed, 98 deletions(-)
mypy/typeshed/stdlib/builtins.pyi | 127 +-----------------------------
1 file changed, 1 insertion(+), 126 deletions(-)

diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
index efc51fe25..8600a372b 100644
index 0fe6d9a69..1808e28e2 100644
--- a/mypy/typeshed/stdlib/builtins.pyi
+++ b/mypy/typeshed/stdlib/builtins.pyi
@@ -64,7 +64,6 @@ from typing import ( # noqa: Y022,UP035
from typing_extensions import ( # noqa: Y023
Concatenate,
Literal,
- LiteralString,
ParamSpec,
Self,
TypeAlias,
@@ -482,31 +481,16 @@ class str(Sequence[str]):
@@ -65,7 +65,7 @@ from typing import ( # noqa: Y022,UP035
)

# we can't import `Literal` from typing or mypy crashes: see #11247
-from typing_extensions import Literal, LiteralString, Self, TypeIs, TypeVarTuple, deprecated, disjoint_base # noqa: Y023, UP035
+from typing_extensions import Literal, Self, TypeIs, TypeVarTuple, deprecated, disjoint_base # noqa: Y023, UP035

if sys.version_info >= (3, 14):
from _typeshed import AnnotateFunc
@@ -489,20 +489,8 @@ class str(Sequence[str]):
def __new__(cls, object: object = "") -> Self: ...
@overload
def __new__(cls, object: ReadableBuffer, encoding: str = "utf-8", errors: str = "strict") -> Self: ...
-
- @overload
- def capitalize(self: LiteralString) -> LiteralString: ...
- @overload
def capitalize(self) -> str: ... # type: ignore[misc]
-
- @overload
- def casefold(self: LiteralString) -> LiteralString: ...
- @overload
def casefold(self) -> str: ... # type: ignore[misc]
-
- @overload
- def center(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = " ", /) -> LiteralString: ...
- @overload
def center(self, width: SupportsIndex, fillchar: str = " ", /) -> str: ... # type: ignore[misc]

def count(self, sub: str, start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> int: ...
def encode(self, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
@@ -510,17 +498,9 @@ class str(Sequence[str]):
def endswith(
self, suffix: str | tuple[str, ...], start: SupportsIndex | None = None, end: SupportsIndex | None = None, /
) -> bool: ...
-
- @overload
- def expandtabs(self: LiteralString, tabsize: SupportsIndex = 8) -> LiteralString: ...
- @overload
def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]

def find(self, sub: str, start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> int: ...
-
- @overload
- def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
- @overload
def format(self, *args: object, **kwargs: object) -> str: ...

def format_map(self, mapping: _FormatMapMapping, /) -> str: ...
def index(self, sub: str, start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> int: ...
@@ -522,98 +506,34 @@ class str(Sequence[str]):
@@ -537,119 +517,38 @@ class str(Sequence[str]):
def isspace(self) -> bool: ...
def istitle(self) -> bool: ...
def isupper(self) -> bool: ...
-
- @overload
- def join(self: LiteralString, iterable: Iterable[LiteralString], /) -> LiteralString: ...
- @overload
def join(self, iterable: Iterable[str], /) -> str: ... # type: ignore[misc]
-
- @overload
- def ljust(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = " ", /) -> LiteralString: ...
- @overload
def ljust(self, width: SupportsIndex, fillchar: str = " ", /) -> str: ... # type: ignore[misc]
-
- @overload
- def lower(self: LiteralString) -> LiteralString: ...
- @overload
def lower(self) -> str: ... # type: ignore[misc]
-
- @overload
- def lstrip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...
- @overload
def lstrip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]
-
- @overload
- def partition(self: LiteralString, sep: LiteralString, /) -> tuple[LiteralString, LiteralString, LiteralString]: ...
- @overload
def partition(self, sep: str, /) -> tuple[str, str, str]: ... # type: ignore[misc]

if sys.version_info >= (3, 13):
- @overload
- def replace(
Expand All @@ -94,102 +108,127 @@ index efc51fe25..8600a372b 100644
- def removeprefix(self: LiteralString, prefix: LiteralString, /) -> LiteralString: ...
- @overload
def removeprefix(self, prefix: str, /) -> str: ... # type: ignore[misc]
-
- @overload
- def removesuffix(self: LiteralString, suffix: LiteralString, /) -> LiteralString: ...
- @overload
def removesuffix(self, suffix: str, /) -> str: ... # type: ignore[misc]

def rfind(self, sub: str, start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> int: ...
def rindex(self, sub: str, start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> int: ...
-
- @overload
- def rjust(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = " ", /) -> LiteralString: ...
- @overload
def rjust(self, width: SupportsIndex, fillchar: str = " ", /) -> str: ... # type: ignore[misc]
-
- @overload
- def rpartition(self: LiteralString, sep: LiteralString, /) -> tuple[LiteralString, LiteralString, LiteralString]: ...
- @overload
def rpartition(self, sep: str, /) -> tuple[str, str, str]: ... # type: ignore[misc]
-
- @overload
- def rsplit(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...
- @overload
def rsplit(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]
-
- @overload
- def rstrip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...
- @overload
def rstrip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]
-
- @overload
- def split(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...
- @overload
def split(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]
-
- @overload
- def splitlines(self: LiteralString, keepends: bool = False) -> list[LiteralString]: ...
- @overload
def splitlines(self, keepends: bool = False) -> list[str]: ... # type: ignore[misc]

def startswith(
self, prefix: str | tuple[str, ...], start: SupportsIndex | None = None, end: SupportsIndex | None = None, /
) -> bool: ...
-
- @overload
- def strip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...
- @overload
def strip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]
-
- @overload
- def swapcase(self: LiteralString) -> LiteralString: ...
- @overload
def swapcase(self) -> str: ... # type: ignore[misc]
-
- @overload
- def title(self: LiteralString) -> LiteralString: ...
- @overload
def title(self) -> str: ... # type: ignore[misc]

def translate(self, table: _TranslateTable, /) -> str: ...
-
- @overload
- def upper(self: LiteralString) -> LiteralString: ...
- @overload
def upper(self) -> str: ... # type: ignore[misc]
-
- @overload
- def zfill(self: LiteralString, width: SupportsIndex, /) -> LiteralString: ...
- @overload
def zfill(self, width: SupportsIndex, /) -> str: ... # type: ignore[misc]
@staticmethod
@overload
@@ -624,39 +544,21 @@ class str(Sequence[str]):

if sys.version_info >= (3, 15):
@@ -677,49 +576,25 @@ class str(Sequence[str]):
@staticmethod
@overload
def maketrans(x: str, y: str, z: str, /) -> dict[int, int | None]: ...
-
- @overload
- def __add__(self: LiteralString, value: LiteralString, /) -> LiteralString: ...
- @overload
def __add__(self, value: str, /) -> str: ... # type: ignore[misc]

# Incompatible with Sequence.__contains__
def __contains__(self, key: str, /) -> bool: ... # type: ignore[override]
def __eq__(self, value: object, /) -> bool: ...
def __ge__(self, value: str, /) -> bool: ...
-
- @overload
- def __getitem__(self: LiteralString, key: SupportsIndex | slice[SupportsIndex | None], /) -> LiteralString: ...
- @overload
def __getitem__(self, key: SupportsIndex | slice[SupportsIndex | None], /) -> str: ... # type: ignore[misc]

def __gt__(self, value: str, /) -> bool: ...
def __hash__(self) -> int: ...
-
- @overload
- def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
- @overload
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]

def __le__(self, value: str, /) -> bool: ...
def __len__(self) -> int: ...
def __lt__(self, value: str, /) -> bool: ...
-
- @overload
- def __mod__(self: LiteralString, value: LiteralString | tuple[LiteralString, ...], /) -> LiteralString: ...
- @overload
def __mod__(self, value: Any, /) -> str: ...
-
- @overload
- def __mul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ...
- @overload
def __mul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]

def __ne__(self, value: object, /) -> bool: ...
-
- @overload
- def __rmul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ...
- @overload
def __rmul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]

def __getnewargs__(self) -> tuple[str]: ...
def __format__(self, format_spec: str, /) -> str: ...
--
2.52.0
2.54.0

Loading
Loading