ORIONIS API REFERENCE

THE ORIONIS API

Build with clarity.

Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.

class documentation

class ModuleInspector: (source)

View In Hierarchy

Load modules and inspect their exported definitions.

Class Method loadClass Load and return a class object from a specified module.
Static Method _collectDirectoryModules Add Python module names from one discovered directory.
Static Method discoverFrozenDataclasses Discover frozen dataclasses in specified modules.
Static Method discoverModules Discover Python modules in a directory tree.
Static Method fileImportsAny Determine if a file imports any target modules using AST analysis.
def loadClass(cls: type, module_path: str | None = None, class_name: str | None = None, *, metadata: dict[str, str] | None = None) -> type: (source)

Load and return a class object from a specified module.

Reuse Python's module cache and retrieve the current class attribute. If not provided directly, module and class names can be extracted from the metadata dictionary.

Parameters
cls:typeReference to the class for caching and method access.
module_path:str or NoneDotted path to the module (e.g., 'orionis.*.config.app.entities.app').
class_name:str or NoneName of the class to retrieve from the module.
metadata:dict[str, str] or None, optionalOptional dictionary containing 'module' and 'class' keys.
Returns
typeThe resolved class object.
Raises
ImportErrorIf the module cannot be imported.
AttributeErrorIf the class does not exist in the module.
TypeErrorIf the resolved attribute is not a class.
def _collectDirectoryModules(package: str, files: list[str], modules: set[str]): (source)

Add Python module names from one discovered directory.

Parameters
package:strDotted package name relative to the application root.
files:list[str]File names reported by the directory walk.
modules:set[str]Destination set shared by the discovery traversal.
Returns
NoneThis method does not return a value.
def discoverFrozenDataclasses(modules: set[str]) -> set[tuple[str, str, str, type[Any]]]: (source)

Discover frozen dataclasses in specified modules.

Traverse the given set of module names, import each module, and inspect its attributes to find frozen dataclasses defined within the module.

Parameters
modules:set[str]Set of module names to inspect.
Returns
set[tuple[str, str, str, type[typing.Any]]]Set of tuples containing file name (without extension), module path, class name, and class type for each discovered frozen dataclass.
Raises
RuntimeErrorIf a module cannot be imported.
def discoverModules(base_path: Path, target_path: Path) -> set[str]: (source)

Discover Python modules in a directory tree.

Traverse the target directory to find Python files and convert their paths to module notation. Exclude virtual environments and import caches. Collect each directory's modules with package initializers normalized to their package module names.

Parameters
base_path:pathlib.PathRoot directory of the application.
target_path:pathlib.PathDirectory to search for Python modules.
Returns
set of strModule names in dot notation, or an empty set for an absent directory.
Raises
ValueErrorIf the target directory is outside the base directory.
OSErrorIf a present directory cannot be traversed completely.
def fileImportsAny(file_path: Path, target_modules: set[str], *, allow_empty: bool = False) -> bool: (source)

Determine if a file imports any target modules using AST analysis.

Parameters
file_path:pathlib.PathPath to the file to analyze.
target_modules:set[str]Set of module names to check for imports.
allow_empty:bool, optionalWhether an empty source is accepted without a required import.
Returns
boolWhether the file imports a target or is explicitly allowed to be empty.