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:
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):
......
......@@ -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.
......
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