optional
¶
Bases: Enum
List of values defining how to handle import errors.
¶
Import a module or a element from the module.
PARAMETER | DESCRIPTION |
---|---|
dependency_group |
Name of dependency group where dependency is defined. Helps communicate a proper error message to the end user.
TYPE:
|
module |
Name of a module.
TYPE:
|
name |
Name of element from the module. If none, returns whole module. Otherwise returns a submodule found using a given name. Defaults to None.
TYPE:
|
error |
Information what to do when module hasn't
been found. Can
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ImportError
|
When required dependency is not installed. |
RETURNS | DESCRIPTION |
---|---|
Optional[ModuleType]
|
Optional[ModuleType]: Module or submodule imported using a name. None if not found. |
Source code in srai/_optional.py
¶
Import list of optional dependencies.
PARAMETER | DESCRIPTION |
---|---|
dependency_group |
Name of optional group that contains dependencies.
TYPE:
|
modules |
List of module names that are expected to be imported.
TYPE:
|
error |
Information what to do when any of the modules hasn't been found. Defaults to ErrorHandle.RAISE.
TYPE:
|