Skip to content

Commit

Permalink
Upgrade to mypy 1.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Oct 20, 2024
1 parent ec5faea commit b4b4449
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.12.1
hooks:
- id: mypy
exclude: tests/data
Expand Down
Empty file.
4 changes: 2 additions & 2 deletions src/pip/_internal/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
import textwrap
from contextlib import suppress
from typing import Any, Dict, Generator, List, Optional, Tuple
from typing import Any, Dict, Generator, List, NoReturn, Optional, Tuple

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

def error(self, msg: str) -> None:
def error(self, msg: str) -> NoReturn:
self.print_usage(sys.stderr)
self.exit(UNKNOWN_ERROR, f"{msg}\n")
2 changes: 1 addition & 1 deletion src/pip/_internal/cli/progress_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _rich_progress_bar(
iterable: Iterable[bytes],
*,
bar_type: str,
size: int,
size: Optional[int],
) -> Generator[bytes, None, None]:
assert bar_type == "on", "This should only be used in the default mode."

Expand Down
6 changes: 3 additions & 3 deletions src/pip/_internal/locations/_distutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from distutils.command.install import SCHEME_KEYS
from distutils.command.install import install as distutils_install_command
from distutils.sysconfig import get_python_lib
from typing import Dict, List, Optional, Union, cast
from typing import Dict, List, Optional, Union

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/network/lazy_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _check_zip(self) -> None:
try:
# For read-only ZIP files, ZipFile only needs
# methods read, seek, seekable and tell.
ZipFile(self) # type: ignore
ZipFile(self)
except BadZipFile:
pass
else:
Expand Down
7 changes: 1 addition & 6 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ def rmtree(
onexc = _onerror_ignore
if onexc is None:
onexc = _onerror_reraise
handler: OnErr = partial(
# `[func, path, Union[ExcInfo, BaseException]] -> Any` is equivalent to
# `Union[([func, path, ExcInfo] -> Any), ([func, path, BaseException] -> Any)]`.
cast(Union[OnExc, OnErr], rmtree_errorhandler),
onexc=onexc,
)
handler: OnErr = partial(rmtree_errorhandler, onexc=onexc)
if sys.version_info >= (3, 12):
# See https://docs.python.org/3.12/whatsnew/3.12.html#shutil.
shutil.rmtree(dir, onexc=handler) # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_make_metadata_file_custom_value_overrides() -> None:

def test_make_metadata_file_custom_contents() -> None:
value = b"hello"
f = default_make_metadata(value=value)
f = default_make_metadata(value=value) # type: ignore[arg-type]
assert f is not None
assert f.contents == value

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def make_metadata_file(
def make_wheel_metadata_file(
name: str,
version: str,
value: Defaulted[Optional[AnyStr]],
value: Defaulted[Union[bytes, str, None]],
tags: Sequence[Tuple[str, str, str]],
updates: Defaulted[Dict[str, HeaderValue]],
) -> Optional[File]:
Expand Down

0 comments on commit b4b4449

Please sign in to comment.