Lightweight dependency injection for Python 3.13+
Warning: Pre-Alpha Software
hdmi is experimental software in active development. Breaking changes may occur until version 1.0.
Documentation: Full Docs | Getting Started | API Reference
- Type-driven dependency discovery — Uses Python's standard type annotations, no decorators needed
- Scope-aware validation — Prevents lifetime bugs at container build time
- Lazy instantiation — Services created just-in-time when first resolved
- Two-phase architecture — Configuration separated from runtime for immutable, validated graphs
pip install hdmiimport asyncio
from hdmi import ContainerBuilder
class DatabaseConnection:
def __init__(self):
self.connected = True
class UserRepository:
def __init__(self, db: DatabaseConnection):
self.db = db
class UserService:
def __init__(self, repo: UserRepository):
self.repo = repo
async def main():
builder = ContainerBuilder()
builder.register(DatabaseConnection)
builder.register(UserRepository)
builder.register(UserService)
container = builder.build() # Validates the dependency graph
user_service = await container.get(UserService) # Auto-wired!
asyncio.run(main())For scoped services (per-request lifecycles), transient services, and scope validation rules, see the documentation.
This project follows strict TDD methodology. See CONTRIBUTING.md for details.
make test # Run all tests
make docs # Build documentation
make help # Show all available commandsMIT License — see LICENSE for details.