Skip to content

Commit

Permalink
Improve the error message displayed on Python requirements conflict (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater authored and shenek committed Dec 31, 2019
1 parent d57a81e commit 27abb49
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
25 changes: 17 additions & 8 deletions poetry/mixology/failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,27 @@ def __init__(self, root): # type: (Incompatibility) -> None
def write(self):
buffer = []

required_python_version = None
required_python_version_notification = False
for incompatibility in self._root.external_incompatibilities:
if isinstance(incompatibility.cause, PythonCause):
required_python_version = incompatibility.cause.root_python_version
break
if not required_python_version_notification:
buffer.append(
"The current project's Python requirement ({}) "
"is not compatible with some of the required "
"packages Python requirement:".format(
incompatibility.cause.root_python_version
)
)
required_python_version_notification = True

if required_python_version is not None:
buffer.append(
"The current project must support the following Python versions: {}".format(
required_python_version
buffer.append(
" - {} requires Python {}".format(
incompatibility.terms[0].dependency.name,
incompatibility.cause.python_version,
)
)
)

if required_python_version_notification:
buffer.append("")

if isinstance(self._root.cause, ConflictCause):
Expand Down
4 changes: 3 additions & 1 deletion tests/mixology/version_solver/test_python_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ def test_dependency_does_not_match_root_python_constraint(root, provider, repo):

add_to_repo(repo, "foo", "1.0.0", python="<3.5")

error = """The current project must support the following Python versions: ^3.6
error = """The current project's Python requirement (^3.6) \
is not compatible with some of the required packages Python requirement:
- foo requires Python <3.5
Because no versions of foo match !=1.0.0
and foo (1.0.0) requires Python <3.5, foo is forbidden.
Expand Down

0 comments on commit 27abb49

Please sign in to comment.