Skip to content

Commit 952af40

Browse files
committed
Fix DependencyCache version solving inconsistency with nested prerelease constraints
1 parent 89659e3 commit 952af40

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/poetry/mixology/version_solver.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,22 @@ def _search_for(self, dependency: Dependency) -> list[DependencyPackage]:
5656
)
5757

5858
packages = self.cache.get(key)
59-
if packages is None:
60-
packages = self.provider.search_for(dependency)
61-
else:
59+
60+
if packages:
6261
packages = [
6362
p for p in packages if dependency.constraint.allows(p.package.version)
6463
]
6564

65+
# provider.search_for() normally does not include pre-release packages
66+
# (unless requested), but will include them if there are no other
67+
# eligible package versions for a version constraint.
68+
#
69+
# Therefore, if the eligible versions have been filtered down to
70+
# nothing, we need to call provider.search_for() again as it may return
71+
# additional results this time.
72+
if not packages:
73+
packages = self.provider.search_for(dependency)
74+
6675
self.cache[key] = packages
6776

6877
return packages

0 commit comments

Comments
 (0)