Commit c78503e5 by Sébastien Eustace Committed by GitHub

Improve the error message displayed on Python requirements conflict (#1681)

parent 2fa4678d
...@@ -31,18 +31,27 @@ class _Writer: ...@@ -31,18 +31,27 @@ class _Writer:
def write(self): def write(self):
buffer = [] buffer = []
required_python_version = None required_python_version_notification = False
for incompatibility in self._root.external_incompatibilities: for incompatibility in self._root.external_incompatibilities:
if isinstance(incompatibility.cause, PythonCause): if isinstance(incompatibility.cause, PythonCause):
required_python_version = incompatibility.cause.root_python_version if not required_python_version_notification:
break 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( buffer.append(
"The current project must support the following Python versions: {}".format( " - {} requires Python {}".format(
required_python_version incompatibility.terms[0].dependency.name,
incompatibility.cause.python_version,
) )
) )
if required_python_version_notification:
buffer.append("") buffer.append("")
if isinstance(self._root.cause, ConflictCause): if isinstance(self._root.cause, ConflictCause):
......
...@@ -8,7 +8,9 @@ def test_dependency_does_not_match_root_python_constraint(root, provider, repo): ...@@ -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") 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 Because no versions of foo match !=1.0.0
and foo (1.0.0) requires Python <3.5, foo is forbidden. and foo (1.0.0) requires Python <3.5, foo is forbidden.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment