Install & Compatibility
Where this runs
tested against v0.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
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.133s · 17.9MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.7s · import 0.123s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
factory
✓ from objectory import factory
AbstractFactory
✓ from objectory import AbstractFactory
Registry
✓ from objectory import Registry
Demonstrates the three main ways to use Objectory: direct factory instantiation, abstract factory inheritance, and dynamic class registration with a Registry.
from objectory import factory, AbstractFactory, Registry
# 1. Basic factory usage with a built-in type
obj_list = factory("builtins.list")
print(f"Created list: {obj_list}")
obj_list_init = factory("builtins.list", [1, 2, 3])
print(f"Created list with data: {obj_list_init}")
# 2. AbstractFactory pattern
class BaseProduct(metaclass=AbstractFactory):
pass
class ConcreteProductA(BaseProduct):
def __init__(self, name="ProductA"):
self.name = name
class ConcreteProductB(BaseProduct):
def __init__(self, value=100):
self.value = value
product_a = BaseProduct.factory("ConcreteProductA", name="SpecialA")
print(f"Created product A: {product_a.name}")
product_b = BaseProduct.factory("ConcreteProductB")
print(f"Created product B value: {product_b.value}")
# 3. Registry pattern
my_registry = Registry()
@my_registry.register()
class RegisteredClass:
def __init__(self, message="Hello from registry!"):
self.message = message
registered_instance = my_registry.factory("RegisteredClass", message="Dynamic message!")
print(f"Created registered instance: {registered_instance.message}")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'objectory'
The 'objectory' package is not installed in your current Python environment.
fixRun `pip install objectory` to install the library.
ValueError: Cannot create object for type 'NonExistentClass'
The string identifier passed to `factory` or `Registry.factory` does not correspond to an existing or registered class/function.
fixVerify that 'NonExistentClass' is correctly spelled, accessible in the current scope, or properly registered with the `Registry` or `AbstractFactory` base class.
TypeError: __init__() missing X required positional arguments
The arguments provided to `factory` (or `AbstractFactory.factory`, `Registry.factory`) do not match the `__init__` signature of the class being instantiated.
fixEnsure that the `*args` and `**kwargs` passed to the factory method align with the constructor requirements of the target class.
Upgrade
Version history
0.3.1latest on PyPI · released Dec 19, 2025
Audit
Dependencies
pythonrequiredRequires Python 3.10 or newer.