ClassRegistry (phx-class-registry) is a Python library that implements a powerful Factory+Registry pattern for Python classes, enabling the definition of global factories that generate new class instances based on configurable keys. It supports service registries and integration with setuptools's entry_points system for extensibility. The current version is 5.2.1 and it maintains an active release cadence, supporting the three most recent Python versions.
pip install phx-class-registryVerified import paths — ran on the pinned version, not inferred.
This example demonstrates creating a typed ClassRegistry, registering classes using a decorator with keys, and then instantiating objects from the registry using subscript notation.
Consult the official 'Upgrading to ClassRegistry v5' guide on ReadTheDocs to adapt your imports and code structure.
Upgrade your Python environment to version 3.12 or newer. For projects requiring older Python versions, pin `phx-class-registry` to `<5.1.0` (for Python 3.10) or `<5.2.0` (for Python 3.11).
Change `from class_registry.auto_register import AutoRegister` to `from class_registry.base import AutoRegister` and use `AutoRegister(my_registry)` as a base class for auto-registration.
Always use `pip install phx-class-registry`. If you have `class-registry` installed, uninstall it with `pip uninstall class-registry`.
If you subclassed `MutableRegistry`, update your base class to `BaseMutableRegistry`.
Uninstall `class-registry` with `pip uninstall class-registry` and then install the correct package: `pip install phx-class-registry`.
Update your import and usage to `from class_registry import BaseMutableRegistry` and use `BaseMutableRegistry` instead of `MutableRegistry`.
Ensure that the class you intend to retrieve has been correctly decorated with `@your_registry.register('my_key')` using the exact key string, and that the key used for retrieval matches it.No dependency data recorded yet.