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

Store failure cause and provide to _get_preference #84

Merged
merged 9 commits into from
Sep 26, 2021
5 changes: 4 additions & 1 deletion src/resolvelib/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(self, provider, reporter):
self._p = provider
self._r = reporter
self._states = []
self._failure_casues = []
notatallshaw marked this conversation as resolved.
Show resolved Hide resolved

@property
def state(self):
Expand Down Expand Up @@ -185,6 +186,7 @@ def _get_preference(self, name):
self.state.criteria,
operator.attrgetter("information"),
),
failure_causes=self._failure_causes
)

def _is_current_pin_satisfying(self, name, criterion):
Expand Down Expand Up @@ -369,11 +371,12 @@ def resolve(self, requirements, max_rounds):
# Backtrack if pinning fails. The backtrack process puts us in
# an unpinned state, so we can work on it in the next round.
success = self._backtrack()
self._failure_causes = [i for c in failure_causes for i in c.information]
notatallshaw marked this conversation as resolved.
Show resolved Hide resolved

# Dead ends everywhere. Give up.
if not success:
causes = [i for c in failure_causes for i in c.information]
notatallshaw marked this conversation as resolved.
Show resolved Hide resolved
raise ResolutionImpossible(causes)
raise ResolutionImpossible(self._failure_causes)
else:
# Pinning was successful. Push a new state to do another pin.
self._push_new_state()
Expand Down