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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 805d7fc06a8bee350959512e0908a18a87b7f8c2 Mon Sep 17 00:00:00 2001
From 3229a6066cff3d80d6cb923322c2d42a300d0be3 Mon Sep 17 00:00:00 2001
From: Shantanu <[email protected]>
Date: Mon, 26 Sep 2022 12:55:07 -0700
Subject: [PATCH] Remove use of LiteralString in builtins (#13743)
Expand All @@ -8,7 +8,7 @@ Subject: [PATCH] Remove use of LiteralString in builtins (#13743)
1 file changed, 1 insertion(+), 99 deletions(-)

diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
index c7ab95482..3e93da36e 100644
index 969d16876..044e264d2 100644
--- a/mypy/typeshed/stdlib/builtins.pyi
+++ b/mypy/typeshed/stdlib/builtins.pyi
@@ -63,7 +63,6 @@ from typing import ( # noqa: Y022,UP035
Expand All @@ -19,10 +19,10 @@ index c7ab95482..3e93da36e 100644
ParamSpec,
Self,
TypeAlias,
@@ -468,31 +467,16 @@ class str(Sequence[str]):
def __new__(cls, object: object = ...) -> Self: ...
@@ -480,31 +479,16 @@ class str(Sequence[str]):
def __new__(cls, object: object = "") -> Self: ...
@overload
def __new__(cls, object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
def __new__(cls, object: ReadableBuffer, encoding: str = "utf-8", errors: str = "strict") -> Self: ...
- @overload
- def capitalize(self: LiteralString) -> LiteralString: ...
- @overload
Expand All @@ -35,23 +35,23 @@ index c7ab95482..3e93da36e 100644
- 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 = ..., end: SupportsIndex | None = ..., /) -> int: ...
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: ...
def endswith(
self, suffix: str | tuple[str, ...], start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /
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 = ..., end: SupportsIndex | None = ..., /) -> int: ...
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 = ..., end: SupportsIndex | None = ..., /) -> int: ...
@@ -508,98 +492,34 @@ class str(Sequence[str]):
def index(self, sub: str, start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> int: ...
@@ -520,98 +504,34 @@ class str(Sequence[str]):
def isspace(self) -> bool: ...
def istitle(self) -> bool: ...
def isupper(self) -> bool: ...
Expand Down Expand Up @@ -98,8 +98,8 @@ index c7ab95482..3e93da36e 100644
- 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 = ..., end: SupportsIndex | None = ..., /) -> int: ...
def rindex(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
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
Expand All @@ -125,7 +125,7 @@ index c7ab95482..3e93da36e 100644
- @overload
def splitlines(self, keepends: bool = False) -> list[str]: ... # type: ignore[misc]
def startswith(
self, prefix: str | tuple[str, ...], start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /
self, prefix: str | tuple[str, ...], start: SupportsIndex | None = None, end: SupportsIndex | None = None, /
) -> bool: ...
- @overload
- def strip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...
Expand All @@ -150,7 +150,7 @@ index c7ab95482..3e93da36e 100644
def zfill(self, width: SupportsIndex, /) -> str: ... # type: ignore[misc]
@staticmethod
@overload
@@ -610,39 +530,21 @@ class str(Sequence[str]):
@@ -622,39 +542,21 @@ class str(Sequence[str]):
@staticmethod
@overload
def maketrans(x: str, y: str, z: str, /) -> dict[int, int | None]: ...
Expand Down Expand Up @@ -192,5 +192,5 @@ index c7ab95482..3e93da36e 100644
def __getnewargs__(self) -> tuple[str]: ...
def __format__(self, format_spec: str, /) -> str: ...
--
2.50.1
2.51.1

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 438dbb1300b77331940d7db8f010e97305745116 Mon Sep 17 00:00:00 2001
From 7678bc3f80e4d3f04a0ff0ee3a7d51f49ae4c465 Mon Sep 17 00:00:00 2001
From: Marc Mueller <[email protected]>
Date: Sat, 21 Dec 2024 22:36:38 +0100
Subject: [PATCH] Revert Remove redundant inheritances from Iterator in
Expand Down Expand Up @@ -36,10 +36,10 @@ index d663f5d93..f43178e4d 100644
@property
def _exception(self) -> BaseException | None: ...
diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
index f2dd00079..784ee7eac 100644
index 044e264d2..6d813f172 100644
--- a/mypy/typeshed/stdlib/builtins.pyi
+++ b/mypy/typeshed/stdlib/builtins.pyi
@@ -1209,7 +1209,7 @@ class frozenset(AbstractSet[_T_co]):
@@ -1210,7 +1210,7 @@ class frozenset(AbstractSet[_T_co]):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

@disjoint_base
Expand All @@ -48,7 +48,7 @@ index f2dd00079..784ee7eac 100644
def __new__(cls, iterable: Iterable[_T], start: int = 0) -> Self: ...
def __iter__(self) -> Self: ...
def __next__(self) -> tuple[int, _T]: ...
@@ -1405,7 +1405,7 @@ else:
@@ -1404,7 +1404,7 @@ else:
exit: _sitebuiltins.Quitter

@disjoint_base
Expand All @@ -57,7 +57,7 @@ index f2dd00079..784ee7eac 100644
@overload
def __new__(cls, function: None, iterable: Iterable[_T | None], /) -> Self: ...
@overload
@@ -1469,7 +1469,7 @@ license: _sitebuiltins._Printer
@@ -1468,7 +1468,7 @@ license: _sitebuiltins._Printer

def locals() -> dict[str, Any]: ...
@disjoint_base
Expand All @@ -66,7 +66,7 @@ index f2dd00079..784ee7eac 100644
# 3.14 adds `strict` argument.
if sys.version_info >= (3, 14):
@overload
@@ -1776,7 +1776,7 @@ def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex
@@ -1775,7 +1775,7 @@ def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex
quit: _sitebuiltins.Quitter

@disjoint_base
Expand All @@ -75,15 +75,15 @@ index f2dd00079..784ee7eac 100644
@overload
def __new__(cls, sequence: Reversible[_T], /) -> Iterator[_T]: ... # type: ignore[misc]
@overload
@@ -1840,7 +1840,7 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
@@ -1839,7 +1839,7 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
@overload
def vars(object: Any = ..., /) -> dict[str, Any]: ...
@disjoint_base
-class zip(Generic[_T_co]):
+class zip(Iterator[_T_co]):
if sys.version_info >= (3, 10):
@overload
def __new__(cls, *, strict: bool = ...) -> zip[Any]: ...
def __new__(cls, *, strict: bool = False) -> zip[Any]: ...
diff --git a/mypy/typeshed/stdlib/csv.pyi b/mypy/typeshed/stdlib/csv.pyi
index 2c8e7109c..4ed0ab1d8 100644
--- a/mypy/typeshed/stdlib/csv.pyi
Expand Down Expand Up @@ -326,5 +326,5 @@ index 6b0f1ba94..882cd143c 100644
@property
def connection(self) -> Connection: ...
--
2.51.0
2.51.1

7 changes: 4 additions & 3 deletions mypy/typeshed/stdlib/_csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ else:
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...

def writer(
csvfile: SupportsWrite[str],
fileobj: SupportsWrite[str],
/,
dialect: _DialectLike = "excel",
*,
Expand All @@ -106,7 +106,7 @@ def writer(
strict: bool = False,
) -> _writer: ...
def reader(
csvfile: Iterable[str],
iterable: Iterable[str],
/,
dialect: _DialectLike = "excel",
*,
Expand All @@ -121,7 +121,8 @@ def reader(
) -> _reader: ...
def register_dialect(
name: str,
dialect: type[Dialect | csv.Dialect] = ...,
/,
dialect: type[Dialect | csv.Dialect] | str = "excel",
*,
delimiter: str = ",",
quotechar: str | None = '"',
Expand Down
10 changes: 5 additions & 5 deletions mypy/typeshed/stdlib/_frozen_importlib_external.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class SourceLoader(_LoaderBasics):
def get_source(self, fullname: str) -> str | None: ...
def path_stats(self, path: str) -> Mapping[str, Any]: ...
def source_to_code(
self, data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive, path: ReadableBuffer | StrPath
self, data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive, path: bytes | StrPath
) -> types.CodeType: ...
def get_code(self, fullname: str) -> types.CodeType | None: ...

Expand All @@ -109,8 +109,8 @@ class FileLoader:
path: str
def __init__(self, fullname: str, path: str) -> None: ...
def get_data(self, path: str) -> bytes: ...
def get_filename(self, name: str | None = None) -> str: ...
def load_module(self, name: str | None = None) -> types.ModuleType: ...
def get_filename(self, fullname: str | None = None) -> str: ...
def load_module(self, fullname: str | None = None) -> types.ModuleType: ...
if sys.version_info >= (3, 10):
def get_resource_reader(self, name: str | None = None) -> importlib.readers.FileReader: ...
else:
Expand All @@ -126,7 +126,7 @@ class SourceFileLoader(importlib.abc.FileLoader, FileLoader, importlib.abc.Sourc
def source_to_code( # type: ignore[override] # incompatible with InspectLoader.source_to_code
self,
data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive,
path: ReadableBuffer | StrPath,
path: bytes | StrPath,
*,
_optimize: int = -1,
) -> types.CodeType: ...
Expand All @@ -137,7 +137,7 @@ class SourcelessFileLoader(importlib.abc.FileLoader, FileLoader, _LoaderBasics):

class ExtensionFileLoader(FileLoader, _LoaderBasics, importlib.abc.ExecutionLoader):
def __init__(self, name: str, path: str) -> None: ...
def get_filename(self, name: str | None = None) -> str: ...
def get_filename(self, fullname: str | None = None) -> str: ...
def get_source(self, fullname: str) -> None: ...
def create_module(self, spec: ModuleSpec) -> types.ModuleType: ...
def exec_module(self, module: types.ModuleType) -> None: ...
Expand Down
3 changes: 3 additions & 0 deletions mypy/typeshed/stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ class SupportsIter(Protocol[_T_co]):
class SupportsAiter(Protocol[_T_co]):
def __aiter__(self) -> _T_co: ...

class SupportsLen(Protocol):
def __len__(self) -> int: ...

class SupportsLenAndGetItem(Protocol[_T_co]):
def __len__(self) -> int: ...
def __getitem__(self, k: int, /) -> _T_co: ...
Expand Down
39 changes: 29 additions & 10 deletions mypy/typeshed/stdlib/ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1744,10 +1744,20 @@ if sys.version_info < (3, 14):
_T = _TypeVar("_T", bound=AST)

if sys.version_info >= (3, 13):
@overload
def parse(
source: _T,
filename: str | bytes | os.PathLike[Any] = "<unknown>",
mode: Literal["exec", "eval", "func_type", "single"] = "exec",
*,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
optimize: Literal[-1, 0, 1, 2] = -1,
) -> _T: ...
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
filename: str | bytes | os.PathLike[Any] = "<unknown>",
mode: Literal["exec"] = "exec",
*,
type_comments: bool = False,
Expand All @@ -1757,7 +1767,7 @@ if sys.version_info >= (3, 13):
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any],
filename: str | bytes | os.PathLike[Any],
mode: Literal["eval"],
*,
type_comments: bool = False,
Expand All @@ -1767,7 +1777,7 @@ if sys.version_info >= (3, 13):
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any],
filename: str | bytes | os.PathLike[Any],
mode: Literal["func_type"],
*,
type_comments: bool = False,
Expand All @@ -1777,7 +1787,7 @@ if sys.version_info >= (3, 13):
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any],
filename: str | bytes | os.PathLike[Any],
mode: Literal["single"],
*,
type_comments: bool = False,
Expand Down Expand Up @@ -1814,7 +1824,7 @@ if sys.version_info >= (3, 13):
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
filename: str | bytes | os.PathLike[Any] = "<unknown>",
mode: str = "exec",
*,
type_comments: bool = False,
Expand All @@ -1823,10 +1833,19 @@ if sys.version_info >= (3, 13):
) -> mod: ...

else:
@overload
def parse(
source: _T,
filename: str | bytes | os.PathLike[Any] = "<unknown>",
mode: Literal["exec", "eval", "func_type", "single"] = "exec",
*,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
) -> _T: ...
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
filename: str | bytes | os.PathLike[Any] = "<unknown>",
mode: Literal["exec"] = "exec",
*,
type_comments: bool = False,
Expand All @@ -1835,7 +1854,7 @@ else:
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any],
filename: str | bytes | os.PathLike[Any],
mode: Literal["eval"],
*,
type_comments: bool = False,
Expand All @@ -1844,7 +1863,7 @@ else:
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any],
filename: str | bytes | os.PathLike[Any],
mode: Literal["func_type"],
*,
type_comments: bool = False,
Expand All @@ -1853,7 +1872,7 @@ else:
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any],
filename: str | bytes | os.PathLike[Any],
mode: Literal["single"],
*,
type_comments: bool = False,
Expand Down Expand Up @@ -1886,7 +1905,7 @@ else:
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
filename: str | bytes | os.PathLike[Any] = "<unknown>",
mode: str = "exec",
*,
type_comments: bool = False,
Expand Down
Loading