Overview#
hazrakah (הזרקה) is a tiny but powerful DI library for Python.
Features#
Supports Singleton, Transient, and Instance lifetimes.
Hierarchical scoping; Isolate registrations and/or resolves. optionally use a context manager to deterministically tear down a scope and its resolved objects.
Namespaced Registrations; Register types into named scopes and resolve with priority chains. Allows multiple implementations of the same interface to coexist.
Protocols, ABCs, and Concretes can be registered against Factory Functions and Concretes.
Lifetime Decorators; (OPTIONAL) Types decorated with
@singleton,@transientor@instancedcan be registered with a single call toregister_decorated(), simplifying orchestration.Implicit Multi-Registration; Types decorated with
@providesbind to all provided types (unless explicit types are specified during registration.)Fluent API; All registration methods return
self, enabling method-chained container setup.Time-bound Caching; The
Cached[T]generic type wraps a zero-argument factory so its result is produced once and re-used until the TTL window elapses.
Contents#
- Overview
- Quick Start
- Reference
- hazrakah
- Container Scopes
- What Are Scopes?
create_scope()- Registration Inheritance
- Shadowing
- Fluent Chaining Across Scopes
- Inheritance of Container Flags
- One-Way Visibility
- Singleton Lifecycle Across Scopes
- Context Manager Teardown
- Child Scope Teardown
- Transitive Teardown
- Exception Handling
- Self-Resolution
- User-Owned Objects
- Namespaced Registrations
- SKILL
- MIT License
- Contact