AutoRegistry is a Python library that implements an automatic registry design pattern, enabling the mapping of string names to functionality (classes or functions) without manual lookup dictionaries. It supports inheritance-based registration, decorator-based registration, and module-level traversal for automatic setup. The library is actively maintained with consistent minor and patch releases, currently at version 1.2.1.
pip install autoregistryVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `Registry` with class inheritance. Subclasses of `Pokemon` are automatically registered by their lowercase name, allowing them to be retrieved via dictionary-like access on the base `Pokemon` class.
Upgrade to `autoregistry` version 1.2.1 or later, which includes fixes to reduce the strictness of `KeyCollisionError` for hot-reloading scenarios.
Update to `autoregistry` 1.2.1 or newer. This version specifically addresses `KeyCollisionErrors` when registering multiple same-name classes to `autoregistry.pydantic.BaseModel`.
Upgrade to `autoregistry` version 1.0.2 or later, which contains fixes for `attrs` decorator compatibility issues with `Registry` subclasses and `slots`. Users should ensure their `attrs` integration is on a supported `autoregistry` version.
Upgrade to `autoregistry` version 1.1.2 or later, which includes a fix for module registry name preprocessing, ensuring consistent and correct naming.
Install the package using pip: 'pip install autoregistry'.
Ensure the correct import statement: 'from autoregistry import Registry'.
Use the 'Registry' object as a decorator or access its methods directly, without calling it as a function.
Ensure that the class or function is properly registered and that the correct name is used when accessing it.
Use the 'Registry' object as a decorator to register functions or classes, or assign them directly to the registry.