Skip to content

Commit

Permalink
check now raises Unresolved. Introduce missing function.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 13, 2022
1 parent 62e72eb commit 86a664c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v0.3.0
======

``check()`` now raises an ``Unresolved`` exception, an iterable
indicating the unresolved dependencies.

Added ``missing()`` method to generate missing dependencies for
an EntryPoint.

v0.2.0
======

Expand Down
20 changes: 16 additions & 4 deletions nspektr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ def visit(req, seen=set()):
return traverse(find_direct_dependencies(dist, extras), visit)


class Unresolved(Exception):
def __iter__(self):
return iter(self.args[0])


def missing(ep):
"""
Generate the unresolved dependencies (if any) of ep.
"""
return unsatisfied(find_dependencies(ep.dist, repair_extras(ep.extras)))


def check(ep):
"""
>>> ep, = metadata.entry_points(group='console_scripts', name='pip')
Expand All @@ -126,8 +138,8 @@ def check(ep):
>>> check(ep)
Traceback (most recent call last):
...
ValueError: ('Unable to resolve all dependencies',...
nspektr.Unresolved: [...]
"""
missing = list(unsatisfied(find_dependencies(ep.dist, repair_extras(ep.extras))))
if missing:
raise ValueError("Unable to resolve all dependencies", missing)
missed = list(missing(ep))
if missed:
raise Unresolved(missed)

0 comments on commit 86a664c

Please sign in to comment.