Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7b6e3b6

Browse files
committedJan 29, 2025··
Return dependencies lazily in resolvelib provider
While ideally we wouldn't prepare any candidates when not necessary, pip has grown a lot of metadata checks (for reporting bad metadata, skipping candidates with unsupported legacy metadata, etc.) so it's not really feasible to stop preparing the candidate upon creation. However, we can create the candidates one-by-one as they're processed instead of all dependencies at once. This is necessary so the resolver can process requires-python first without processing other dependencies. Are there potential side-effects...? Probably. A test suite run didn't flag anything though.
1 parent e21141a commit 7b6e3b6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/pip/_internal/resolution/resolvelib/provider.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ def _eligible_for_upgrade(identifier: str) -> bool:
242242
def is_satisfied_by(self, requirement: Requirement, candidate: Candidate) -> bool:
243243
return requirement.is_satisfied_by(candidate)
244244

245-
def get_dependencies(self, candidate: Candidate) -> Sequence[Requirement]:
245+
def get_dependencies(self, candidate: Candidate) -> Iterable[Requirement]:
246246
with_requires = not self._ignore_dependencies
247-
return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
247+
return (r for r in candidate.iter_dependencies(with_requires) if r is not None)
248248

249249
@staticmethod
250250
def is_backtrack_cause(

0 commit comments

Comments
 (0)
Please sign in to comment.