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 ModuleInspector: (source)
Load modules and inspect their exported definitions.
| Class Method | load |
Load and return a class object from a specified module. |
| Static Method | _collect |
Add Python module names from one discovered directory. |
| Static Method | discover |
Discover frozen dataclasses in specified modules. |
| Static Method | discover |
Discover Python modules in a directory tree. |
| Static Method | file |
Determine if a file imports any target modules using AST analysis. |
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:type | Reference to the class for caching and method access. |
modulestr or None | Dotted path to the module (e.g., 'orionis.*.config.app.entities.app'). |
classstr or None | Name of the class to retrieve from the module. |
metadata:dict[str, str] or None, optional | Optional dictionary containing 'module' and 'class' keys. |
| Returns | |
type | The resolved class object. |
| Raises | |
ImportError | If the module cannot be imported. |
AttributeError | If the class does not exist in the module. |
TypeError | If the resolved attribute is not a class. |
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 | |
RuntimeError | If a module cannot be imported. |
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 | |
basepathlib.Path | Root directory of the application. |
targetpathlib.Path | Directory to search for Python modules. |
| Returns | |
set of str | Module names in dot notation, or an empty set for an absent directory. |
| Raises | |
ValueError | If the target directory is outside the base directory. |
OSError | If a present directory cannot be traversed completely. |
Path, target_modules: set[ str], *, allow_empty: bool = False) -> bool:
(source)
¶
Determine if a file imports any target modules using AST analysis.
| Parameters | |
filepathlib.Path | Path to the file to analyze. |
targetset[str] | Set of module names to check for imports. |
allowbool, optional | Whether an empty source is accepted without a required import. |
| Returns | |
bool | Whether the file imports a target or is explicitly allowed to be empty. |