Skip to content

Commit

Permalink
Merge pull request #11270 from uranusjr/upgrade-pre-commit-hooks
Browse files Browse the repository at this point in the history
Upgrade pre-commit hooks
  • Loading branch information
uranusjr committed Jul 18, 2022
2 parents b655841 + 360b963 commit c9cb7f4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: 'src/pip/_vendor/'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.3.0
hooks:
- id: check-builtin-literals
- id: check-added-large-files
Expand All @@ -17,7 +17,7 @@ repos:
exclude: .patch

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black

Expand All @@ -39,7 +39,7 @@ repos:
files: \.py$

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.942
rev: v0.961
hooks:
- id: mypy
exclude: tests/data
Expand Down
4 changes: 3 additions & 1 deletion src/pip/_internal/metadata/importlib/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class BasePath(Protocol):
in both classes *that we need*.
"""

name: str
@property
def name(self) -> str:
raise NotImplementedError()

@property
def parent(self) -> "BasePath":
Expand Down
18 changes: 16 additions & 2 deletions src/pip/_internal/metadata/importlib/_dists.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
import os
import pathlib
import zipfile
from typing import Collection, Dict, Iterable, Iterator, Mapping, Optional, Sequence
from typing import (
Collection,
Dict,
Iterable,
Iterator,
Mapping,
Optional,
Sequence,
cast,
)

from pip._vendor.packaging.requirements import Requirement
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
Expand Down Expand Up @@ -173,7 +182,12 @@ def iter_entry_points(self) -> Iterable[BaseEntryPoint]:
return self._dist.entry_points

def _metadata_impl(self) -> email.message.Message:
return self._dist.metadata
# From Python 3.10+, importlib.metadata declares PackageMetadata as the
# return type. This protocol is unfortunately a disaster now and misses
# a ton of fields that we need, including get() and get_payload(). We
# rely on the implementation that the object is actually a Message now,
# until upstream can improve the protocol. (python/cpython#94952)
return cast(email.message.Message, self._dist.metadata)

def iter_provided_extras(self) -> Iterable[str]:
return (
Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/network/lazy_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def __enter__(self) -> "LazyZipOverHTTP":
self._file.__enter__()
return self

def __exit__(self, *exc: Any) -> Optional[bool]:
return self._file.__exit__(*exc)
def __exit__(self, *exc: Any) -> None:
self._file.__exit__(*exc)

@contextmanager
def _stay(self) -> Generator[None, None, None]:
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/network/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def is_secure_origin(self, location: Link) -> bool:
continue

try:
addr = ipaddress.ip_address(origin_host)
addr = ipaddress.ip_address(origin_host or "")
network = ipaddress.ip_network(secure_host)
except ValueError:
# We don't have both a valid address or a valid network, so
Expand Down

0 comments on commit c9cb7f4

Please sign in to comment.