Skip to content

Commit 3b3fde2

Browse files
authored
Fix the pip/_internal/distributions annotations (#10074)
1 parent ce86dc8 commit 3b3fde2

File tree

6 files changed

+25
-24
lines changed

6 files changed

+25
-24
lines changed

news/10074.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed all the annotations from ``pip/_internal/distributions``.

src/pip/_internal/distributions/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
from pip._internal.req.req_install import InstallRequirement
55

66

7-
def make_distribution_for_install_requirement(install_req):
8-
# type: (InstallRequirement) -> AbstractDistribution
7+
def make_distribution_for_install_requirement(
8+
install_req: InstallRequirement,
9+
) -> AbstractDistribution:
910
"""Returns a Distribution for the given InstallRequirement"""
1011
# Editable requirements will always be source distributions. They use the
1112
# legacy logic until we create a modern standard for them.

src/pip/_internal/distributions/base.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@ class AbstractDistribution(metaclass=abc.ABCMeta):
2323
above metadata.
2424
"""
2525

26-
def __init__(self, req):
27-
# type: (InstallRequirement) -> None
26+
def __init__(self, req: InstallRequirement) -> None:
2827
super().__init__()
2928
self.req = req
3029

3130
@abc.abstractmethod
32-
def get_pkg_resources_distribution(self):
33-
# type: () -> Optional[Distribution]
31+
def get_pkg_resources_distribution(self) -> Optional[Distribution]:
3432
raise NotImplementedError()
3533

3634
@abc.abstractmethod
37-
def prepare_distribution_metadata(self, finder, build_isolation):
38-
# type: (PackageFinder, bool) -> None
35+
def prepare_distribution_metadata(
36+
self, finder: PackageFinder, build_isolation: bool
37+
) -> None:
3938
raise NotImplementedError()

src/pip/_internal/distributions/installed.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class InstalledDistribution(AbstractDistribution):
1313
been computed.
1414
"""
1515

16-
def get_pkg_resources_distribution(self):
17-
# type: () -> Optional[Distribution]
16+
def get_pkg_resources_distribution(self) -> Optional[Distribution]:
1817
return self.req.satisfied_by
1918

20-
def prepare_distribution_metadata(self, finder, build_isolation):
21-
# type: (PackageFinder, bool) -> None
19+
def prepare_distribution_metadata(
20+
self, finder: PackageFinder, build_isolation: bool
21+
) -> None:
2222
pass

src/pip/_internal/distributions/sdist.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class SourceDistribution(AbstractDistribution):
1919
generated, either using PEP 517 or using the legacy `setup.py egg_info`.
2020
"""
2121

22-
def get_pkg_resources_distribution(self):
23-
# type: () -> Distribution
22+
def get_pkg_resources_distribution(self) -> Distribution:
2423
return self.req.get_dist()
2524

26-
def prepare_distribution_metadata(self, finder, build_isolation):
27-
# type: (PackageFinder, bool) -> None
25+
def prepare_distribution_metadata(
26+
self, finder: PackageFinder, build_isolation: bool
27+
) -> None:
2828
# Load pyproject.toml, to determine whether PEP 517 is to be used
2929
self.req.load_pyproject_toml()
3030

@@ -35,10 +35,10 @@ def prepare_distribution_metadata(self, finder, build_isolation):
3535

3636
self.req.prepare_metadata()
3737

38-
def _setup_isolation(self, finder):
39-
# type: (PackageFinder) -> None
40-
def _raise_conflicts(conflicting_with, conflicting_reqs):
41-
# type: (str, Set[Tuple[str, str]]) -> None
38+
def _setup_isolation(self, finder: PackageFinder) -> None:
39+
def _raise_conflicts(
40+
conflicting_with: str, conflicting_reqs: Set[Tuple[str, str]]
41+
) -> None:
4242
format_string = (
4343
"Some build dependencies for {requirement} "
4444
"conflict with {conflicting_with}: {description}."

src/pip/_internal/distributions/wheel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ class WheelDistribution(AbstractDistribution):
1313
This does not need any preparation as wheels can be directly unpacked.
1414
"""
1515

16-
def get_pkg_resources_distribution(self):
17-
# type: () -> Distribution
16+
def get_pkg_resources_distribution(self) -> Distribution:
1817
"""Loads the metadata from the wheel file into memory and returns a
1918
Distribution that uses it, not relying on the wheel file or
2019
requirement.
@@ -29,6 +28,7 @@ def get_pkg_resources_distribution(self):
2928
z, self.req.name, self.req.local_file_path
3029
)
3130

32-
def prepare_distribution_metadata(self, finder, build_isolation):
33-
# type: (PackageFinder, bool) -> None
31+
def prepare_distribution_metadata(
32+
self, finder: PackageFinder, build_isolation: bool
33+
) -> None:
3434
pass

0 commit comments

Comments
 (0)