Skip to content

Commit 6958e28

Browse files
authored
Merge pull request #13022 from hauntsaninja/mypy112
Upgrade to mypy 1.12.1
2 parents be46900 + b4b4449 commit 6958e28

File tree

9 files changed

+11
-16
lines changed

9 files changed

+11
-16
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repos:
2828
args: [--fix, --exit-non-zero-on-fix]
2929

3030
- repo: https://github.com/pre-commit/mirrors-mypy
31-
rev: v1.10.0
31+
rev: v1.12.1
3232
hooks:
3333
- id: mypy
3434
exclude: tests/data

news/10EC0CC0-C535-4B04-8924-CBF3DAA3315D.trivial.rst

Whitespace-only changes.

src/pip/_internal/cli/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
import textwrap
88
from contextlib import suppress
9-
from typing import Any, Dict, Generator, List, Optional, Tuple
9+
from typing import Any, Dict, Generator, List, NoReturn, Optional, Tuple
1010

1111
from pip._internal.cli.status_codes import UNKNOWN_ERROR
1212
from pip._internal.configuration import Configuration, ConfigurationError
@@ -289,6 +289,6 @@ def get_default_values(self) -> optparse.Values:
289289
defaults[option.dest] = option.check_value(opt_str, default)
290290
return optparse.Values(defaults)
291291

292-
def error(self, msg: str) -> None:
292+
def error(self, msg: str) -> NoReturn:
293293
self.print_usage(sys.stderr)
294294
self.exit(UNKNOWN_ERROR, f"{msg}\n")

src/pip/_internal/cli/progress_bars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _rich_progress_bar(
2525
iterable: Iterable[bytes],
2626
*,
2727
bar_type: str,
28-
size: int,
28+
size: Optional[int],
2929
) -> Generator[bytes, None, None]:
3030
assert bar_type == "on", "This should only be used in the default mode."
3131

src/pip/_internal/locations/_distutils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from distutils.command.install import SCHEME_KEYS
2222
from distutils.command.install import install as distutils_install_command
2323
from distutils.sysconfig import get_python_lib
24-
from typing import Dict, List, Optional, Union, cast
24+
from typing import Dict, List, Optional, Union
2525

2626
from pip._internal.models.scheme import Scheme
2727
from pip._internal.utils.compat import WINDOWS
@@ -64,7 +64,7 @@ def distutils_scheme(
6464
obj: Optional[DistutilsCommand] = None
6565
obj = d.get_command_obj("install", create=True)
6666
assert obj is not None
67-
i = cast(distutils_install_command, obj)
67+
i: distutils_install_command = obj
6868
# NOTE: setting user or home has the side-effect of creating the home dir
6969
# or user base for installations during finalize_options()
7070
# ideally, we'd prefer a scheme class that has no side-effects.
@@ -78,7 +78,7 @@ def distutils_scheme(
7878
i.root = root or i.root
7979
i.finalize_options()
8080

81-
scheme = {}
81+
scheme: Dict[str, str] = {}
8282
for key in SCHEME_KEYS:
8383
scheme[key] = getattr(i, "install_" + key)
8484

src/pip/_internal/network/lazy_wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _check_zip(self) -> None:
159159
try:
160160
# For read-only ZIP files, ZipFile only needs
161161
# methods read, seek, seekable and tell.
162-
ZipFile(self) # type: ignore
162+
ZipFile(self)
163163
except BadZipFile:
164164
pass
165165
else:

src/pip/_internal/utils/misc.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,7 @@ def rmtree(
129129
onexc = _onerror_ignore
130130
if onexc is None:
131131
onexc = _onerror_reraise
132-
handler: OnErr = partial(
133-
# `[func, path, Union[ExcInfo, BaseException]] -> Any` is equivalent to
134-
# `Union[([func, path, ExcInfo] -> Any), ([func, path, BaseException] -> Any)]`.
135-
cast(Union[OnExc, OnErr], rmtree_errorhandler),
136-
onexc=onexc,
137-
)
132+
handler: OnErr = partial(rmtree_errorhandler, onexc=onexc)
138133
if sys.version_info >= (3, 12):
139134
# See https://docs.python.org/3.12/whatsnew/3.12.html#shutil.
140135
shutil.rmtree(dir, onexc=handler) # type: ignore

tests/lib/test_wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_make_metadata_file_custom_value_overrides() -> None:
8080

8181
def test_make_metadata_file_custom_contents() -> None:
8282
value = b"hello"
83-
f = default_make_metadata(value=value)
83+
f = default_make_metadata(value=value) # type: ignore[arg-type]
8484
assert f is not None
8585
assert f.contents == value
8686

tests/lib/wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def make_metadata_file(
109109
def make_wheel_metadata_file(
110110
name: str,
111111
version: str,
112-
value: Defaulted[Optional[AnyStr]],
112+
value: Defaulted[Union[bytes, str, None]],
113113
tags: Sequence[Tuple[str, str, str]],
114114
updates: Defaulted[Dict[str, HeaderValue]],
115115
) -> Optional[File]:

0 commit comments

Comments
 (0)