medkit._import

medkit._import#

Functions#

import_optional(→ types.ModuleType)

Import an optional dependency or raise an appropriate error message.

Module Contents#

medkit._import.import_optional(name: str, extra: str | None = None) types.ModuleType#

Import an optional dependency or raise an appropriate error message.

Parameters:
namestr

Module name to import.

extrastr, optional

Group of optional dependencies to suggest installing if the import fails. If unspecified, assume the extra is named after the caller’s module.

Returns:
ModuleType

The successfully imported module.

Raises:
ModuleNotFoundError

In case the requested import failed.