Skip to content

Commit 52133ba

Browse files
refactor much of RequirementPreparer and add lengthy docs
1 parent ad93d54 commit 52133ba

File tree

3 files changed

+181
-153
lines changed

3 files changed

+181
-153
lines changed

news/12871.trivial.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Refactor much of ``RequirementPreparer`` to avoid duplicated code paths for metadata-only requirements.

src/pip/_internal/distributions/__init__.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
def make_distribution_for_install_requirement(
99
install_req: InstallRequirement,
1010
) -> AbstractDistribution:
11-
"""Returns a Distribution for the given InstallRequirement"""
11+
"""Returns an AbstractDistribution for the given InstallRequirement.
12+
13+
As AbstractDistribution only covers installable artifacts, this method may only be
14+
invoked at the conclusion of a resolve, when the RequirementPreparer has downloaded
15+
the file corresponding to the resolved dist. Commands which intend to consume
16+
metadata-only resolves without downloading should not call this method or
17+
consume AbstractDistribution objects.
18+
"""
1219
# Only pre-installed requirements will have a .satisfied_by dist.
1320
if install_req.satisfied_by:
1421
return InstalledDistribution(install_req)

0 commit comments

Comments
 (0)