Skip to content

Commit 21c0055

Browse files
authored
Merge branch 'master' into strictnone
2 parents 46f65df + d95531d commit 21c0055

198 files changed

Lines changed: 5100 additions & 1513 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/source/command_line.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,15 @@ potentially problematic or redundant in some way.
537537
print(x + "bad")
538538
539539
To help prevent mypy from generating spurious warnings, the "Statement is
540-
unreachable" warning will be silenced in exactly two cases:
540+
unreachable" warning will be silenced in exactly three cases:
541541

542542
1. When the unreachable statement is a ``raise`` statement, is an
543543
``assert False`` statement, or calls a function that has the :py:data:`~typing.NoReturn`
544544
return type hint. In other words, when the unreachable statement
545545
throws an error or terminates the program in some way.
546-
2. When the unreachable statement was *intentionally* marked as unreachable
546+
2. When the unreachable statement is ``return NotImplemented``. This
547+
is allowed by mypy due to its use in operator overloading.
548+
3. When the unreachable statement was *intentionally* marked as unreachable
547549
using :ref:`version_and_platform_checks`.
548550

549551
.. note::

docs/source/error_code_list2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Example:
3232
3333
# mypy: disallow-any-generics
3434
35-
# Error: Missing type parameters for generic type "list" [type-arg]
35+
# Error: Missing type arguments for generic type "list" [type-arg]
3636
def remove_dups(items: list) -> list:
3737
...
3838

misc/typeshed_patches/0001-Partially-revert-Clean-up-argparse-hacks.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 84a9d586544a0408d4654f57f83a93cb048070fb Mon Sep 17 00:00:00 2001
1+
From b6d495c10e79fb56ff64f8fb90c87894090f9cbe Mon Sep 17 00:00:00 2001
22
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
33
Date: Sat, 15 Feb 2025 20:11:06 +0100
44
Subject: [PATCH] Partially revert Clean up argparse hacks
@@ -8,7 +8,7 @@ Subject: [PATCH] Partially revert Clean up argparse hacks
88
1 file changed, 5 insertions(+), 3 deletions(-)
99

1010
diff --git a/mypy/typeshed/stdlib/argparse.pyi b/mypy/typeshed/stdlib/argparse.pyi
11-
index b9fa31139..3c3ba116a 100644
11+
index ae99eb036..c87b8f4fc 100644
1212
--- a/mypy/typeshed/stdlib/argparse.pyi
1313
+++ b/mypy/typeshed/stdlib/argparse.pyi
1414
@@ -2,7 +2,7 @@ import sys
@@ -41,5 +41,5 @@ index b9fa31139..3c3ba116a 100644
4141
default: Any = ...,
4242
type: _ActionType = ...,
4343
--
44-
2.50.1
44+
2.52.0
4545

misc/typeshed_patches/0001-Remove-use-of-LiteralString-in-builtins-13743.patch

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 3229a6066cff3d80d6cb923322c2d42a300d0be3 Mon Sep 17 00:00:00 2001
1+
From ed11d7e0204868ef1a43c17ed950372b1d78f497 Mon Sep 17 00:00:00 2001
22
From: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
33
Date: Mon, 26 Sep 2022 12:55:07 -0700
44
Subject: [PATCH] Remove use of LiteralString in builtins (#13743)
@@ -8,18 +8,18 @@ Subject: [PATCH] Remove use of LiteralString in builtins (#13743)
88
1 file changed, 1 insertion(+), 99 deletions(-)
99

1010
diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
11-
index 969d16876..044e264d2 100644
11+
index 693dd0b77..8acdeadff 100644
1212
--- a/mypy/typeshed/stdlib/builtins.pyi
1313
+++ b/mypy/typeshed/stdlib/builtins.pyi
14-
@@ -63,7 +63,6 @@ from typing import ( # noqa: Y022,UP035
14+
@@ -64,7 +64,6 @@ from typing import ( # noqa: Y022,UP035
1515
from typing_extensions import ( # noqa: Y023
1616
Concatenate,
1717
Literal,
1818
- LiteralString,
1919
ParamSpec,
2020
Self,
2121
TypeAlias,
22-
@@ -480,31 +479,16 @@ class str(Sequence[str]):
22+
@@ -482,31 +481,16 @@ class str(Sequence[str]):
2323
def __new__(cls, object: object = "") -> Self: ...
2424
@overload
2525
def __new__(cls, object: ReadableBuffer, encoding: str = "utf-8", errors: str = "strict") -> Self: ...
@@ -51,7 +51,7 @@ index 969d16876..044e264d2 100644
5151
def format(self, *args: object, **kwargs: object) -> str: ...
5252
def format_map(self, mapping: _FormatMapMapping, /) -> str: ...
5353
def index(self, sub: str, start: SupportsIndex | None = None, end: SupportsIndex | None = None, /) -> int: ...
54-
@@ -520,98 +504,34 @@ class str(Sequence[str]):
54+
@@ -522,98 +506,34 @@ class str(Sequence[str]):
5555
def isspace(self) -> bool: ...
5656
def istitle(self) -> bool: ...
5757
def isupper(self) -> bool: ...
@@ -150,7 +150,7 @@ index 969d16876..044e264d2 100644
150150
def zfill(self, width: SupportsIndex, /) -> str: ... # type: ignore[misc]
151151
@staticmethod
152152
@overload
153-
@@ -622,39 +542,21 @@ class str(Sequence[str]):
153+
@@ -624,39 +544,21 @@ class str(Sequence[str]):
154154
@staticmethod
155155
@overload
156156
def maketrans(x: str, y: str, z: str, /) -> dict[int, int | None]: ...
@@ -192,5 +192,5 @@ index 969d16876..044e264d2 100644
192192
def __getnewargs__(self) -> tuple[str]: ...
193193
def __format__(self, format_spec: str, /) -> str: ...
194194
--
195-
2.51.1
195+
2.52.0
196196

misc/typeshed_patches/0001-Revert-Remove-redundant-inheritances-from-Iterator.patch

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 7678bc3f80e4d3f04a0ff0ee3a7d51f49ae4c465 Mon Sep 17 00:00:00 2001
1+
From 69791281c2c5e919cea9a77c4a771f79d9e70384 Mon Sep 17 00:00:00 2001
22
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
33
Date: Sat, 21 Dec 2024 22:36:38 +0100
44
Subject: [PATCH] Revert Remove redundant inheritances from Iterator in
@@ -36,10 +36,10 @@ index d663f5d93..f43178e4d 100644
3636
@property
3737
def _exception(self) -> BaseException | None: ...
3838
diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
39-
index 044e264d2..6d813f172 100644
39+
index 8acdeadff..5a3bb5908 100644
4040
--- a/mypy/typeshed/stdlib/builtins.pyi
4141
+++ b/mypy/typeshed/stdlib/builtins.pyi
42-
@@ -1210,7 +1210,7 @@ class frozenset(AbstractSet[_T_co]):
42+
@@ -1226,7 +1226,7 @@ class frozenset(AbstractSet[_T_co]):
4343
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
4444

4545
@disjoint_base
@@ -48,7 +48,7 @@ index 044e264d2..6d813f172 100644
4848
def __new__(cls, iterable: Iterable[_T], start: int = 0) -> Self: ...
4949
def __iter__(self) -> Self: ...
5050
def __next__(self) -> tuple[int, _T]: ...
51-
@@ -1404,7 +1404,7 @@ else:
51+
@@ -1413,7 +1413,7 @@ else:
5252
exit: _sitebuiltins.Quitter
5353

5454
@disjoint_base
@@ -57,7 +57,7 @@ index 044e264d2..6d813f172 100644
5757
@overload
5858
def __new__(cls, function: None, iterable: Iterable[_T | None], /) -> Self: ...
5959
@overload
60-
@@ -1468,7 +1468,7 @@ license: _sitebuiltins._Printer
60+
@@ -1477,7 +1477,7 @@ license: _sitebuiltins._Printer
6161

6262
def locals() -> dict[str, Any]: ...
6363
@disjoint_base
@@ -66,7 +66,7 @@ index 044e264d2..6d813f172 100644
6666
# 3.14 adds `strict` argument.
6767
if sys.version_info >= (3, 14):
6868
@overload
69-
@@ -1775,7 +1775,7 @@ def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex
69+
@@ -1784,7 +1784,7 @@ def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex
7070
quit: _sitebuiltins.Quitter
7171

7272
@disjoint_base
@@ -75,7 +75,7 @@ index 044e264d2..6d813f172 100644
7575
@overload
7676
def __new__(cls, sequence: Reversible[_T], /) -> Iterator[_T]: ... # type: ignore[misc]
7777
@overload
78-
@@ -1839,7 +1839,7 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
78+
@@ -1848,7 +1848,7 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
7979
@overload
8080
def vars(object: Any = ..., /) -> dict[str, Any]: ...
8181
@disjoint_base
@@ -107,7 +107,7 @@ index 2c8e7109c..4ed0ab1d8 100644
107107
restkey: _T | None
108108
restval: str | Any | None
109109
diff --git a/mypy/typeshed/stdlib/fileinput.pyi b/mypy/typeshed/stdlib/fileinput.pyi
110-
index 910d63814..eb942bc55 100644
110+
index 6778b7648..95164de2f 100644
111111
--- a/mypy/typeshed/stdlib/fileinput.pyi
112112
+++ b/mypy/typeshed/stdlib/fileinput.pyi
113113
@@ -1,8 +1,8 @@
@@ -118,7 +118,7 @@ index 910d63814..eb942bc55 100644
118118
from types import GenericAlias, TracebackType
119119
-from typing import IO, Any, AnyStr, Generic, Literal, Protocol, overload, type_check_only
120120
+from typing import IO, Any, AnyStr, Literal, Protocol, overload, type_check_only
121-
from typing_extensions import Self, TypeAlias
121+
from typing_extensions import Self, TypeAlias, deprecated
122122

123123
__all__ = [
124124
@@ -105,7 +105,7 @@ def fileno() -> int: ...
@@ -131,7 +131,7 @@ index 910d63814..eb942bc55 100644
131131
# encoding and errors are added
132132
@overload
133133
diff --git a/mypy/typeshed/stdlib/itertools.pyi b/mypy/typeshed/stdlib/itertools.pyi
134-
index fe4ccbdf8..73745fe92 100644
134+
index 8a924ad8b..5c2bf7f83 100644
135135
--- a/mypy/typeshed/stdlib/itertools.pyi
136136
+++ b/mypy/typeshed/stdlib/itertools.pyi
137137
@@ -28,7 +28,7 @@ _Predicate: TypeAlias = Callable[[_T], object]
@@ -166,7 +166,7 @@ index fe4ccbdf8..73745fe92 100644
166166
-class accumulate(Generic[_T]):
167167
+class accumulate(Iterator[_T]):
168168
@overload
169-
def __new__(cls, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> Self: ...
169+
def __new__(cls, iterable: Iterable[_T], func: None = None, *, initial: _T | None = None) -> Self: ...
170170
@overload
171171
@@ -64,7 +64,7 @@ class accumulate(Generic[_T]):
172172
def __next__(self) -> _T: ...
@@ -239,7 +239,7 @@ index fe4ccbdf8..73745fe92 100644
239239
+class zip_longest(Iterator[_T_co]):
240240
# one iterable (fillvalue doesn't matter)
241241
@overload
242-
def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = ...) -> zip_longest[tuple[_T1]]: ...
242+
def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = None) -> zip_longest[tuple[_T1]]: ...
243243
@@ -202,7 +202,7 @@ class zip_longest(Generic[_T_co]):
244244
def __next__(self) -> _T_co: ...
245245

@@ -291,8 +291,8 @@ index fe4ccbdf8..73745fe92 100644
291291
- class batched(Generic[_T_co]):
292292
+ class batched(Iterator[tuple[_T_co, ...]], Generic[_T_co]):
293293
if sys.version_info >= (3, 13):
294-
def __new__(cls, iterable: Iterable[_T_co], n: int, *, strict: bool = False) -> Self: ...
295-
else:
294+
@overload
295+
def __new__(cls, iterable: Iterable[_T], n: Literal[1], *, strict: Literal[True]) -> batched[tuple[_T]]: ...
296296
diff --git a/mypy/typeshed/stdlib/multiprocessing/pool.pyi b/mypy/typeshed/stdlib/multiprocessing/pool.pyi
297297
index b79f9e773..f276372d0 100644
298298
--- a/mypy/typeshed/stdlib/multiprocessing/pool.pyi
@@ -313,10 +313,10 @@ index b79f9e773..f276372d0 100644
313313
def __iter__(self) -> Self: ...
314314
def next(self, timeout: float | None = None) -> _T: ...
315315
diff --git a/mypy/typeshed/stdlib/sqlite3/__init__.pyi b/mypy/typeshed/stdlib/sqlite3/__init__.pyi
316-
index 6b0f1ba94..882cd143c 100644
316+
index 04b978b1b..e4604144f 100644
317317
--- a/mypy/typeshed/stdlib/sqlite3/__init__.pyi
318318
+++ b/mypy/typeshed/stdlib/sqlite3/__init__.pyi
319-
@@ -407,7 +407,7 @@ class Connection:
319+
@@ -408,7 +408,7 @@ class Connection:
320320
) -> Literal[False]: ...
321321

322322
@disjoint_base
@@ -326,5 +326,5 @@ index 6b0f1ba94..882cd143c 100644
326326
@property
327327
def connection(self) -> Connection: ...
328328
--
329-
2.51.1
329+
2.52.0
330330

misc/typeshed_patches/0001-Revert-sum-literal-integer-change-13961.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 16b0b50ec77e470f24145071acde5274a1de53a0 Mon Sep 17 00:00:00 2001
1+
From 0e30b762e8335f02e19977c055ac7b98e707991c Mon Sep 17 00:00:00 2001
22
From: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
33
Date: Sat, 29 Oct 2022 12:47:21 -0700
44
Subject: [PATCH] Revert sum literal integer change (#13961)
@@ -19,10 +19,10 @@ within mypy, I might pursue upstreaming this in typeshed.
1919
1 file changed, 1 insertion(+), 1 deletion(-)
2020

2121
diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
22-
index 900c4c93f..d874edd8f 100644
22+
index 5a3bb5908..0f2196070 100644
2323
--- a/mypy/typeshed/stdlib/builtins.pyi
2424
+++ b/mypy/typeshed/stdlib/builtins.pyi
25-
@@ -1782,7 +1782,7 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
25+
@@ -1835,7 +1835,7 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
2626
# without creating many false-positive errors (see #7578).
2727
# Instead, we special-case the most common examples of this: bool and literal integers.
2828
@overload
@@ -32,5 +32,5 @@ index 900c4c93f..d874edd8f 100644
3232
def sum(iterable: Iterable[_SupportsSumNoDefaultT], /) -> _SupportsSumNoDefaultT | Literal[0]: ...
3333
@overload
3434
--
35-
2.49.0
35+
2.52.0
3636

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
From 85c0cfb55c6211c2a47c3f45d2ff28fa76f8204b Mon Sep 17 00:00:00 2001
1+
From 80a710e0e2c09612c6fc30c644f2052450e69ccd Mon Sep 17 00:00:00 2001
22
From: AlexWaygood <alex.waygood@gmail.com>
33
Date: Mon, 1 May 2023 20:34:55 +0100
4-
Subject: [PATCH] Revert typeshed ctypes change Since the plugin provides
5-
superior type checking:
6-
https://github.com/python/mypy/pull/13987#issuecomment-1310863427 A manual
7-
cherry-pick of e437cdf.
4+
Subject: [PATCH] Revert typeshed ctypes change
85

6+
The plugin provides superior type checking:
7+
https://github.com/python/mypy/pull/13987#issuecomment-1310863427
8+
A manual cherry-pick of e437cdf.
99
---
1010
mypy/typeshed/stdlib/_ctypes.pyi | 6 +-----
1111
1 file changed, 1 insertion(+), 5 deletions(-)
1212

1313
diff --git a/mypy/typeshed/stdlib/_ctypes.pyi b/mypy/typeshed/stdlib/_ctypes.pyi
14-
index 944685646..dc8c7b2ca 100644
14+
index be7792818..b7a3fb104 100644
1515
--- a/mypy/typeshed/stdlib/_ctypes.pyi
1616
+++ b/mypy/typeshed/stdlib/_ctypes.pyi
17-
@@ -289,11 +289,7 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
17+
@@ -320,11 +320,7 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
1818
def _type_(self) -> type[_CT]: ...
1919
@_type_.setter
2020
def _type_(self, value: type[_CT]) -> None: ...
@@ -28,5 +28,5 @@ index 944685646..dc8c7b2ca 100644
2828
# TODO: These methods cannot be annotated correctly at the moment.
2929
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT
3030
--
31-
2.49.0
31+
2.52.0
3232

mypy-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# and the pins in setup.py
33
typing_extensions>=4.6.0
44
mypy_extensions>=1.0.0
5-
pathspec>=0.9.0
5+
pathspec>=1.0.0
66
tomli>=1.1.0; python_version<'3.11'
77
librt>=0.6.2; platform_python_implementation != 'PyPy'

0 commit comments

Comments
 (0)