Welcome to nspektr documentation!

class nspektr.NullMarker

Bases: object

evaluate(*args, **kwargs)
classmethod wrap(req: Requirement)
exception nspektr.Unresolved

Bases: Exception

>>> ep, = metadata.entry_points(group='console_scripts', name='pytest')
>>> check(ep)
>>> dist = metadata.distribution('nspektr')

Since ‘docs’ extras are not installed, requesting them should fail.

>>> ep = metadata.EntryPoint(
...     group=None, name=None, value='nspektr [docs]')._for(dist)
>>> check(ep)
Traceback (most recent call last):
nspektr.Unresolved: [...]
nspektr.find_dependencies(dist, extras=None)

Find all reachable dependencies for dist.

dist is an importlib.metadata.Distribution (or similar). TODO: create a suitable protocol for type hint.

>>> deps = find_dependencies(resolve(Requirement('nspektr')))
>>> all(isinstance(dep, Requirement) for dep in deps)
>>> not any('pytest' in str(dep) for dep in deps)
>>> test_deps = find_dependencies(resolve(Requirement('nspektr[testing]')))
>>> any('pytest' in str(dep) for dep in test_deps)
nspektr.find_direct_dependencies(dist, extras=None)

Find direct, declared dependencies for dist.

nspektr.is_satisfied(req: Requirement)

Generate the unresolved dependencies (if any) of ep.

nspektr.resolve(req: Requirement) Distribution

Resolve the requirement to its distribution.

Ignore exception detail for Python 3.9 compatibility.

>>> resolve(Requirement('pytest<3'))  
Traceback (most recent call last):
importlib.metadata.PackageNotFoundError: No package metadata was found for pytest<3
nspektr.traverse(items, visit)

Given an iterable of items, traverse the items.

For each item, visit is called to return any additional items to include in the traversal.

Indices and tables