Skip to content

livery.extensions.python._answers

livery.extensions.python._answers

The python extension's answers: about a package, and about the workspace.

About a package, from its manifest and sources: its version, the files a version is written into, its requirements, the names its code is referenced by, its public modules and what each source references. About the workspace, while pytest is listed: the functions that run the python packages' suites and a package's documentation examples, and the function that widens a change to a module pytest loads as a plugin to every member pytest runs.

Functions:

Name Description
current_version

The version the package's pyproject.toml declares.

version_files

pyproject.toml, and every __init__.py that may carry __version__.

requirements

The package's [project.dependencies], each name to its constraint.

requirement_writers

The pyproject's writer of a requirement on a sibling that holds python.

test_requirements

The package's test extra, each name to its constraint.

test_requirement_writers

The pyproject's writer of a test requirement on a sibling that holds python.

module_roots

The import prefixes the package's code is referenced by.

public_modules

The modules that declare the package's public API.

references

What each python source under src and tests references, one per file.

distributions

The distribution the package releases, as its ecosystem and its name.

executables

The scripts the package's pyproject.toml names in [project.scripts].

registry

The simple index the package is released to, as a probe of its versions.

suite_runner

Answer python.test.runner with the function that runs the suites.

examples_runner

Answer python.examples.runner with the function that runs examples.

plugin_reaches

Answer reaches with the function that follows pytest's plugins.

Attributes:

Name Type Description
ECOSYSTEM

ECOSYSTEM module-attribute

ECOSYSTEM = 'python'

current_version

current_version(package: Package) -> str

The version the package's pyproject.toml declares.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def current_version(package: Package) -> str:
    """The version the package's ``pyproject.toml`` declares."""
    return _backend.current_version(package)

version_files

version_files(package: Package) -> tuple[Path, ...]

pyproject.toml, and every __init__.py that may carry __version__.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def version_files(package: Package) -> tuple[Path, ...]:
    """``pyproject.toml``, and every ``__init__.py`` that may carry ``__version__``."""
    return tuple(_backend.stamp_version(package).homes())

requirements

requirements(package: Package) -> Mapping[str, str]

The package's [project.dependencies], each name to its constraint.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def requirements(package: Package) -> Mapping[str, str]:
    """The package's ``[project.dependencies]``, each name to its constraint."""
    return _backend.declared_requirements(package)

requirement_writers

requirement_writers(package: Package) -> tuple[RequirementWriter, ...]

The pyproject's writer of a requirement on a sibling that holds python.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def requirement_writers(package: Package) -> tuple[RequirementWriter, ...]:
    """The pyproject's writer of a requirement on a sibling that holds python."""
    del package
    return (_backend.declare_requirement,)

test_requirements

test_requirements(package: Package) -> Mapping[str, str]

The package's test extra, each name to its constraint.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def test_requirements(package: Package) -> Mapping[str, str]:
    """The package's ``test`` extra, each name to its constraint."""
    return _backend.declared_test_requirements(package)

test_requirement_writers

test_requirement_writers(package: Package) -> tuple[RequirementWriter, ...]

The pyproject's writer of a test requirement on a sibling that holds python.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def test_requirement_writers(package: Package) -> tuple[RequirementWriter, ...]:
    """The pyproject's writer of a test requirement on a sibling that holds python."""
    del package
    return (_backend.declare_test_requirement,)

module_roots

module_roots(package: Package) -> tuple[str, ...]

The import prefixes the package's code is referenced by.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def module_roots(package: Package) -> tuple[str, ...]:
    """The import prefixes the package's code is referenced by."""
    return tuple(_backend.module_roots(package))

public_modules

public_modules(package: Package) -> tuple[str, ...]

The modules that declare the package's public API.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def public_modules(package: Package) -> tuple[str, ...]:
    """The modules that declare the package's public API."""
    return tuple(_backend.public_modules(package))

references

references(package: Package) -> tuple[SourceReferences, ...]

What each python source under src and tests references, one per file.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def references(package: Package) -> tuple[SourceReferences, ...]:
    """What each python source under ``src`` and ``tests`` references, one per file."""
    return _backend.references(package)

distributions

distributions(package: Package) -> tuple[tuple[str, str], ...]

The distribution the package releases, as its ecosystem and its name.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def distributions(package: Package) -> tuple[tuple[str, str], ...]:
    """The distribution the package releases, as its ecosystem and its name."""
    return ((ECOSYSTEM, package.name),)

executables

executables(package: Package) -> tuple[str, ...]

The scripts the package's pyproject.toml names in [project.scripts].

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def executables(package: Package) -> tuple[str, ...]:
    """The scripts the package's ``pyproject.toml`` names in ``[project.scripts]``."""
    return _backend.scripts(package)

registry

registry(package: Package) -> Registry

The simple index the package is released to, as a probe of its versions.

The index is the python target the registry ladder resolves for the package's workspace (livery.workshop.registry), and the probe reads it with the target's credential: an authenticated index, a forge's own registry or a private owner's, answers only with it, and an anonymous probe would wait for a version the index already serves.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def registry(package: Package) -> Registry:
    """The simple index the package is released to, as a probe of its versions.

    The index is the python target the registry ladder resolves for the
    package's workspace ([livery.workshop.registry][]), and the probe
    reads it with the target's credential: an authenticated index, a
    forge's own registry or a private owner's, answers only with it, and
    an anonymous probe would wait for a version the index already
    serves.
    """
    from livery.forge import SimpleRegistry
    from livery.workshop import registry as resolved

    target = resolved(package.root, ECOSYSTEM)
    return SimpleRegistry(target.url, token=target.token)

suite_runner

suite_runner(root: Path) -> Callable[..., None]

Answer python.test.runner with the function that runs the suites.

pytest's test step asks with the workspace root, which the answer does not depend on, and calls the answer with the words for pytest, the packages whose suites run in one call, the root, the test files that stand for each package's suite, the CI point and whether the run is measured.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def suite_runner(root: Path) -> Callable[..., None]:
    """Answer ``python.test.runner`` with the function that runs the suites.

    pytest's test step asks with the workspace root, which the answer
    does not depend on, and calls the answer with the words for pytest,
    the packages whose suites run in one call, the root, the test files
    that stand for each package's suite, the CI point and whether the
    run is measured.
    """
    del root
    return _backend.run_test

examples_runner

examples_runner(root: Path) -> Callable[[Package, Path, tuple[str, ...], tuple[str, ...]], None]

Answer python.examples.runner with the function that runs examples.

pytest's examples step asks with the workspace root, which the answer does not depend on, and calls the answer once per package with the package, the root, the example files the run names (empty for all of them) and the words for pytest.

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def examples_runner(
    root: Path,
) -> Callable[[Package, Path, tuple[str, ...], tuple[str, ...]], None]:
    """Answer ``python.examples.runner`` with the function that runs examples.

    pytest's examples step asks with the workspace root, which the
    answer does not depend on, and calls the answer once per package
    with the package, the root, the example files the run names (empty
    for all of them) and the words for pytest.
    """
    del root
    return _backend.run_examples

plugin_reaches

plugin_reaches(root: Path) -> tuple[Callable[[Changes], Mapping[str, tuple[str, tuple[str, ...]]]], ...]

Answer reaches with the function that follows pytest's plugins.

The affected engine asks with the workspace root, which the answer does not depend on, and calls the function with the run's change. pytest loads a module a member names under pytest11 into every session, so a change to one reaches every member pytest runs over (livery.extensions.python._backend.plugin_reaches).

Source code in packages/extensions/python/src/livery/extensions/python/_answers.py
def plugin_reaches(
    root: Path,
) -> tuple[Callable[[Changes], Mapping[str, tuple[str, tuple[str, ...]]]], ...]:
    """Answer ``reaches`` with the function that follows pytest's plugins.

    The affected engine asks with the workspace root, which the answer
    does not depend on, and calls the function with the run's change.
    pytest loads a module a member names under ``pytest11`` into every
    session, so a change to one reaches every member pytest runs over
    ([livery.extensions.python._backend.plugin_reaches][]).
    """
    del root
    return (_backend.plugin_reaches,)