Skip to content

Commit c9cb7f4

Browse files
authored
Merge pull request #11270 from uranusjr/upgrade-pre-commit-hooks
Upgrade pre-commit hooks
2 parents b655841 + 360b963 commit c9cb7f4

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ exclude: 'src/pip/_vendor/'
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.2.0
5+
rev: v4.3.0
66
hooks:
77
- id: check-builtin-literals
88
- id: check-added-large-files
@@ -17,7 +17,7 @@ repos:
1717
exclude: .patch
1818

1919
- repo: https://github.com/psf/black
20-
rev: 22.3.0
20+
rev: 22.6.0
2121
hooks:
2222
- id: black
2323

@@ -39,7 +39,7 @@ repos:
3939
files: \.py$
4040

4141
- repo: https://github.com/pre-commit/mirrors-mypy
42-
rev: v0.942
42+
rev: v0.961
4343
hooks:
4444
- id: mypy
4545
exclude: tests/data

src/pip/_internal/metadata/importlib/_compat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ class BasePath(Protocol):
1313
in both classes *that we need*.
1414
"""
1515

16-
name: str
16+
@property
17+
def name(self) -> str:
18+
raise NotImplementedError()
1719

1820
@property
1921
def parent(self) -> "BasePath":

src/pip/_internal/metadata/importlib/_dists.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
import os
44
import pathlib
55
import zipfile
6-
from typing import Collection, Dict, Iterable, Iterator, Mapping, Optional, Sequence
6+
from typing import (
7+
Collection,
8+
Dict,
9+
Iterable,
10+
Iterator,
11+
Mapping,
12+
Optional,
13+
Sequence,
14+
cast,
15+
)
716

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

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

178192
def iter_provided_extras(self) -> Iterable[str]:
179193
return (

src/pip/_internal/network/lazy_wheel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ def __enter__(self) -> "LazyZipOverHTTP":
135135
self._file.__enter__()
136136
return self
137137

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

141141
@contextmanager
142142
def _stay(self) -> Generator[None, None, None]:

src/pip/_internal/network/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def is_secure_origin(self, location: Link) -> bool:
465465
continue
466466

467467
try:
468-
addr = ipaddress.ip_address(origin_host)
468+
addr = ipaddress.ip_address(origin_host or "")
469469
network = ipaddress.ip_network(secure_host)
470470
except ValueError:
471471
# We don't have both a valid address or a valid network, so

0 commit comments

Comments
 (0)