Skip to content

Commit fa81394

Browse files
reaperhulkclaude
andauthored
Upgrade mypy to 2.3.0 on Python 3.10+ (#15414)
mypy 2.3 changed the error code for "Too many positional arguments" from [misc] to [call-arg]. Since the Python 3.9 flake job stays on mypy 1.19 (mypy 2.x requires Python 3.10+), no single error code works for both, so use a bare `type: ignore` at those call sites. Claude-Session: https://claude.ai/code/session_01RAxXsKkjKM9hT6CrMdDcpk Co-authored-by: Claude <noreply@anthropic.com>
1 parent 485778d commit fa81394

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

ci-constraints-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ markupsafe==3.0.3
102102
# via jinja2
103103
mypy==1.19.1 ; python_full_version < '3.10'
104104
# via cryptography (pyproject.toml:dev)
105-
mypy==2.1.0 ; python_full_version >= '3.10'
105+
mypy==2.3.0 ; python_full_version >= '3.10'
106106
# via cryptography (pyproject.toml:dev)
107107
mypy-extensions==1.1.0
108108
# via mypy

tests/hazmat/asn1/test_api.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,16 @@ class Example:
249249
# The kw-only init is only enforced in Python >= 3.10, which is
250250
# when the parameter `kw_only` for `dataclasses.datalass` was
251251
# added.
252+
# Bare `type: ignore` because mypy <2.3 reports this as `misc` and
253+
# mypy >=2.3 reports it as `call-arg`.
252254
if sys.version_info < (3, 10):
253-
assert Example(5).foo == 5 # type: ignore[misc]
255+
assert Example(5).foo == 5 # type: ignore
254256
else:
255257
with pytest.raises(
256258
TypeError,
257259
match="takes 1 positional argument but 2 were given",
258260
):
259-
Example(5) # type: ignore[misc]
261+
Example(5) # type: ignore
260262

261263
def test_fail_malformed_root_type(self) -> None:
262264
@asn1.sequence
@@ -564,14 +566,16 @@ class Example:
564566
# The kw-only init is only enforced in Python >= 3.10, which is
565567
# when the parameter `kw_only` for `dataclasses.datalass` was
566568
# added.
569+
# Bare `type: ignore` because mypy <2.3 reports this as `misc` and
570+
# mypy >=2.3 reports it as `call-arg`.
567571
if sys.version_info < (3, 10):
568-
assert Example(5).foo == 5 # type: ignore[misc]
572+
assert Example(5).foo == 5 # type: ignore
569573
else:
570574
with pytest.raises(
571575
TypeError,
572576
match="takes 1 positional argument but 2 were given",
573577
):
574-
Example(5) # type: ignore[misc]
578+
Example(5) # type: ignore
575579

576580
def test_fail_malformed_root_type(self) -> None:
577581
@asn1.set

tests/hazmat/primitives/test_kbkdf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,9 @@ def test_keyword_only_break_location(self, backend):
347347
b"context",
348348
None,
349349
backend,
350-
0, # type: ignore[misc]
350+
# Bare `type: ignore` because mypy <2.3 reports this as
351+
# `misc` and mypy >=2.3 reports it as `call-arg`.
352+
0, # type: ignore
351353
)
352354

353355
def test_invalid_break_location(self):
@@ -771,7 +773,9 @@ def test_keyword_only_break_location(self, backend):
771773
b"context",
772774
None,
773775
backend,
774-
0, # type: ignore[misc]
776+
# Bare `type: ignore` because mypy <2.3 reports this as
777+
# `misc` and mypy >=2.3 reports it as `call-arg`.
778+
0, # type: ignore
775779
)
776780

777781
def test_invalid_break_location(self):

0 commit comments

Comments
 (0)