From bf55229fc6348308989f963feeea8c90d25a1af8 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Wed, 4 Nov 2020 21:27:16 +0800 Subject: [PATCH] Use set to dedup package list in error message --- news/9101.bugfix.rst | 1 + src/pip/_internal/resolution/resolvelib/factory.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 news/9101.bugfix.rst diff --git a/news/9101.bugfix.rst b/news/9101.bugfix.rst new file mode 100644 index 00000000000..441f2a93136 --- /dev/null +++ b/news/9101.bugfix.rst @@ -0,0 +1 @@ +New resolver: Show each requirement in the conflict error message only once to reduce cluttering. diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py index 8e1a68d168d..c65cb7f76f8 100644 --- a/src/pip/_internal/resolution/resolvelib/factory.py +++ b/src/pip/_internal/resolution/resolvelib/factory.py @@ -406,19 +406,19 @@ def describe_trigger(parent): # type: (Candidate) -> str ireq = parent.get_install_requirement() if not ireq or not ireq.comes_from: - return "{} {}".format(parent.name, parent.version) + return "{}=={}".format(parent.name, parent.version) if isinstance(ireq.comes_from, InstallRequirement): return str(ireq.comes_from.name) return str(ireq.comes_from) - triggers = [] + triggers = set() for req, parent in e.causes: if parent is None: # This is a root requirement, so we can report it directly trigger = req.format_for_error() else: trigger = describe_trigger(parent) - triggers.append(trigger) + triggers.add(trigger) if triggers: info = text_join(sorted(triggers))