chunkipy.utils

Shared utility helpers used across chunkipy internals and optional extras.

Functions

format_instructions(*, extra, package_name)

Build the installation hint shown when an optional dependency is missing.

import_dependencies(extra, package_name[, ...])

Import an optional dependency and optionally fetch named attributes.

Exceptions

MissingDependencyError

Raised when an optional dependency required by an API is not installed.

exception chunkipy.utils.MissingDependencyError[source]

Bases: Exception

Raised when an optional dependency required by an API is not installed.

chunkipy.utils.format_instructions(*, extra, package_name)[source]

Build the installation hint shown when an optional dependency is missing.

Return type:

str

Parameters:
  • extra (str)

  • package_name (str)

chunkipy.utils.import_dependencies(extra, package_name, attribute_names=None)[source]

Import an optional dependency and optionally fetch named attributes.

Parameters:
  • extra (str) – Name of the optional extra exposed by the package.

  • package_name (str) – Importable module name.

  • attribute_names (Optional[Iterable[str]]) – Optional attribute names to resolve from the module.

Returns:

The imported module when attribute_names is empty, otherwise a list containing the module followed by the requested attributes.

Raises:

MissingDependencyError – If the module or any requested attribute cannot be imported.