File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed
Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -242,10 +242,27 @@ def get_locked_package(
242242
243243 # If we have an overlapping candidate, we must use it.
244244 if overlapping_candidates :
245- compatible_candidates = [
245+ filtered_compatible_candidates = [
246246 package
247247 for package in compatible_candidates
248248 if package in overlapping_candidates
249249 ]
250250
251+ if not filtered_compatible_candidates :
252+ # TODO: Support this case:
253+ # https://github.com/python-poetry/poetry-plugin-export/issues/183
254+ raise DependencyWalkerError (
255+ f"The `{ dependency .name } ` package has the following compatible"
256+ f" candidates `{ compatible_candidates } `; but, the exporter dependency"
257+ f" walker previously elected `{ overlapping_candidates .pop ()} ` which is"
258+ f" not compatible with the dependency `{ dependency } `. Please contribute"
259+ " to `poetry-plugin-export` to solve this problem."
260+ )
261+
262+ compatible_candidates = filtered_compatible_candidates
263+
251264 return next (iter (compatible_candidates ), None )
265+
266+
267+ class DependencyWalkerError (Exception ):
268+ pass
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ import pytest
4+
5+ from packaging .utils import NormalizedName
6+ from poetry .core .packages .dependency import Dependency
7+ from poetry .core .packages .package import Package
8+
9+ from poetry_plugin_export .walker import DependencyWalkerError
10+ from poetry_plugin_export .walker import walk_dependencies
11+
12+
13+ def test_walk_dependencies_multiple_versions_when_latest_is_not_compatible () -> None :
14+ # TODO: Support this case:
15+ # https://github.com/python-poetry/poetry-plugin-export/issues/183
16+ with pytest .raises (DependencyWalkerError ):
17+ walk_dependencies (
18+ dependencies = [
19+ Dependency ("grpcio" , ">=1.42.0" ),
20+ Dependency ("grpcio" , ">=1.42.0,<=1.49.1" ),
21+ Dependency ("grpcio" , ">=1.47.0,<2.0dev" ),
22+ ],
23+ packages_by_name = {
24+ "grpcio" : [Package ("grpcio" , "1.51.3" ), Package ("grpcio" , "1.49.1" )]
25+ },
26+ root_package_name = NormalizedName ("package-name" ),
27+ )
You can’t perform that action at this time.
0 commit comments