Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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