Skip to content

Commit

Permalink
solver: print more information about packages with source_type when s…
Browse files Browse the repository at this point in the history
…olving fails to avoid weird messages like "Because myapp depends on both demo (1.2.3) and demo (1.2.3), version solving failed."
  • Loading branch information
radoering authored and abn committed May 21, 2022
1 parent 77d8975 commit caffd4f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/poetry/mixology/incompatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ def _terse(self, term: Term, allow_every: bool = False) -> str:
pretty_name: str = term.dependency.pretty_name
return pretty_name

if term.dependency.source_type:
return str(term.dependency)
return f"{term.dependency.pretty_name} ({term.dependency.pretty_constraint})"

def _single_term_where(self, callable: Callable[[Term], bool]) -> Term | None:
Expand Down
20 changes: 20 additions & 0 deletions tests/mixology/version_solver/test_unsolvable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING

from poetry.factory import Factory
Expand Down Expand Up @@ -92,6 +93,25 @@ def test_disjoint_root_constraints(
check_solver_result(root, provider, error=error)


def test_disjoint_root_constraints_path_dependencies(
root: ProjectPackage, provider: Provider, repo: Repository
):
provider.set_package_python_versions("^3.7")
fixtures = Path(__file__).parent.parent.parent / "fixtures"
project_dir = fixtures.joinpath("with_conditional_path_deps")
path1 = project_dir / "demo_one"
root.add_dependency(Factory.create_dependency("demo", {"path": path1}))
path2 = project_dir / "demo_two"
root.add_dependency(Factory.create_dependency("demo", {"path": path2}))

error = (
f"Because myapp depends on both demo (1.2.3 {path1.as_posix()}) "
f"and demo (1.2.3 {path2.as_posix()}), version solving failed."
)

check_solver_result(root, provider, error=error)


def test_no_valid_solution(root: ProjectPackage, provider: Provider, repo: Repository):
root.add_dependency(Factory.create_dependency("a", "*"))
root.add_dependency(Factory.create_dependency("b", "*"))
Expand Down

0 comments on commit caffd4f

Please sign in to comment.