Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the error message displayed on Python requirements conflict #1681

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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