Skip to content

Commit

Permalink
Upgrade to mypy 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Oct 17, 2024
1 parent ec5faea commit ea46e28
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 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.0
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
3 changes: 2 additions & 1 deletion src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Iterator,
List,
Optional,
Protocol,
TextIO,
Tuple,
Type,
Expand Down Expand Up @@ -132,7 +133,7 @@ def rmtree(
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),
rmtree_errorhandler,
onexc=onexc,
)
if sys.version_info >= (3, 12):
Expand Down
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -135,7 +135,7 @@ def test_make_wheel_metadata_file_custom_value_override() -> None:

def test_make_wheel_metadata_file_custom_contents() -> None:
value = b"hello"
f = default_make_wheel_metadata(value=value)
f = default_make_wheel_metadata(value=value) # type: ignore[arg-type]
assert f is not None
assert f.name == "simple-0.1.0.dist-info/WHEEL"
assert f.contents == value
Expand Down

0 comments on commit ea46e28

Please sign in to comment.