From c1f6a379b3a85303f487e1b366e96d9db90cd4e3 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Thu, 25 Aug 2022 13:18:28 +0200 Subject: include offending mapping identifiers in exception when unable to resolve dependencies --- src/hydrilla/proxy/simple_dependency_satisfying.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/hydrilla/proxy') diff --git a/src/hydrilla/proxy/simple_dependency_satisfying.py b/src/hydrilla/proxy/simple_dependency_satisfying.py index f1371db..78a1197 100644 --- a/src/hydrilla/proxy/simple_dependency_satisfying.py +++ b/src/hydrilla/proxy/simple_dependency_satisfying.py @@ -25,7 +25,11 @@ # in a proprietary program, I am not going to enforce this in court. """ -..... +This module contains logic to construct the dependency graph of Haketilo +packages and to perform dependency resolution. + +The approach taken here is a very simplified one. Hopefully, this will at some +point be replaced by a solution based on some SAT solver. """ # Enable using with Python 3.7. @@ -39,8 +43,9 @@ from .. import item_infos from .. import url_patterns +@dc.dataclass(frozen=True) class ImpossibleSituation(HaketiloException): - pass + bad_mapping_identifiers: frozenset[str] @dc.dataclass(frozen=True) @@ -219,13 +224,16 @@ class _ComputationData: if self.mappings.get(depended_identifier) not in choices: _mark_mappings(depended_identifier, reverse_deps, bad_mappings) - if any(identifier in self.required for identifier in bad_mappings): - raise ImpossibleSituation() + bad_required_mappings: list[str] = [] - for identifier in bad_mappings: - if identifier in self.required: - raise ImpossibleSituation() + for identifier in self.required: + if identifier in bad_mappings or identifier not in choices: + bad_required_mappings.append(identifier) + + if len(bad_required_mappings) > 0: + raise ImpossibleSituation(frozenset(bad_required_mappings)) + for identifier in bad_mappings: if identifier in self.mappings: choices.pop(identifier, None) -- cgit v1.2.3