Registry / serialization / autoregistry

autoregistry

JSON →
library1.3.1pypypi✓ verified 22d ago

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 autoregistry
INSTALL
IMPORT
SIG · AUTOREGISTRY
A
autoregistry
serializationpythonv1.3.1
Install
2.4s avg
Import
52ms
Disk
26MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.053s · 27.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.4s · import 0.051s · 28MB
26MB installed
● package 26MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Registry
from autoregistry import Registry
BaseModel
from autoregistry.pydantic import BaseModel
from autoregistry import BaseModel
The Pydantic-enhanced BaseModel is located in the `autoregistry.pydantic` submodule, not directly under `autoregistry`.

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.

from abc import abstractmethod from dataclasses import dataclass from autoregistry import Registry @dataclass class Pokemon(Registry): level: int hp: int @abstractmethod def attack(self, target): """Attack another Pokemon.""" class Charmander(Pokemon): def attack(self, target): return 1 class Pikachu(Pokemon): def attack(self, target): return 2 # Access registered subclasses charmander = Pokemon["charmander"](level=5, hp=40) # Name is auto-derived from class name pikachu = Pokemon["pikachu"](level=7, hp=50) assert charmander.attack(pikachu) == 1 assert isinstance(charmander, Charmander) assert isinstance(pikachu, Pikachu) print(f"Created {charmander.__class__.__name__} (Level: {charmander.level}, HP: {charmander.hp})") print(f"Created {pikachu.__class__.__name__} (Level: {pikachu.level}, HP: {pikachu.hp})")
Debug
Known issues
gotchaEncountering `KeyCollisionError` during module hot-reloading (e.g., in development environments like IPython with `%autoreload`). This could occur if modules containing registered classes were reloaded, leading to re-registration.
fix
Upgrade to `autoregistry` version 1.2.1 or later, which includes fixes to reduce the strictness of `KeyCollisionError` for hot-reloading scenarios.
affects: <1.2.1
gotchaWhen using `autoregistry.pydantic.BaseModel`, registering multiple classes with the same derived name could trigger `KeyCollisionError`.
fix
Update to `autoregistry` 1.2.1 or newer. This version specifically addresses `KeyCollisionErrors` when registering multiple same-name classes to `autoregistry.pydantic.BaseModel`.
affects: <1.2.1
gotchaPotential issues when combining `autoregistry.Registry` subclasses with `attrs` decorators, especially when `slots` are enabled, leading to unexpected behavior or errors.
fix
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.
affects: <1.0.2
gotchaUnexpected behavior or incorrect naming due to issues with module registry name preprocessing, potentially leading to incorrect keys in the registry when using module-based registration.
fix
Upgrade to `autoregistry` version 1.1.2 or later, which includes a fix for module registry name preprocessing, ensuring consistent and correct naming.
affects: <1.1.2
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'autoregistry'
The 'autoregistry' package is not installed in the Python environment.
fix
Install the package using pip: 'pip install autoregistry'.
ImportError: cannot import name 'Registry' from 'autoregistry'
The 'Registry' class is not found in the 'autoregistry' module, possibly due to an incorrect import statement or a version mismatch.
fix
Ensure the correct import statement: 'from autoregistry import Registry'.
TypeError: 'Registry' object is not callable
Attempting to call a 'Registry' object as a function, which is not supported.
fix
Use the 'Registry' object as a decorator or access its methods directly, without calling it as a function.
KeyError: 'classname'
Attempting to access a class or function by a name that has not been registered in the 'Registry' object.
fix
Ensure that the class or function is properly registered and that the correct name is used when accessing it.
AttributeError: 'Registry' object has no attribute 'register'
Attempting to use a 'register' method that does not exist in the 'Registry' class.
fix
Use the 'Registry' object as a decorator to register functions or classes, or assign them directly to the registry.
Upgrade
Version history
1.3.1latest on PyPI · released Jul 8, 2026
Audit
Dependencies
pydanticoptionalRequired only for the `autoregistry.pydantic.BaseModel` integration to combine Pydantic's data validation with AutoRegistry's registration features.
Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources
autoregistry — pip install autoregistry · libregistry