lagom
Lagom is a dependency injection container designed to give you 'just enough' help with building your dependencies.
Decision gist · record as of 2026-08-14
Yes. Lagom is a solid choice for projects needing lightweight dependency injection without framework overhead. Zero runtime dependencies, active maintenance, broad Python version support, and a permissive MIT license make it low-risk. The type-hint-based design integrates well with modern Python tooling. Best suited for teams comfortable with type annotations and seeking minimal configuration; not necessary for very small scripts but valuable for any structured application.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with no runtime dependencies.
- Actively maintained with a recent release (394 days ago) and ongoing commits; supports Python 3.7 through 3.13.
License · maintenance · safety
permissive license (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
last release 2025-07-16 (394 days) · last repo commit 2026-05-24 · 352 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 338,072 downloads/mo, #7,439 on PyPI
Alternatives
Verify before relying
pip install lagom
from lagom import Container
class MyDataSource:
pass
class SomeClass:
def __init__(self, datasource: MyDataSource):
self.datasource = datasource
container = Container()
instance = container[SomeClass]- Performance characteristics and overhead compared to manual dependency management or other DI frameworks.
- Scope of framework integrations beyond the mentioned web framework hooks.
- Thread-safety guarantees under concurrent container access patterns.
What it is and what it does
Lagom is a dependency injection container that uses Python type hints to automatically construct and wire dependencies with minimal configuration. Most of your application code remains unaware of the container; Lagom is invoked only at the top level to assemble the dependency graph. It supports type-based auto-wiring where the container inspects `__init__` method type annotations and recursively builds instances, explicit singleton registration, lambda-based factory functions, and decorators for integrating with web frameworks and async code.
The design philosophy emphasizes minimal intrusion into existing code—you don't need to modify your classes to use Lagom, only to add type hints if you want auto-wiring. It's thread-safe at runtime and fully integrated with mypy for static type checking, making it suitable for both small scripts and larger applications that need structured dependency management without heavyweight framework overhead.
Use it for
- Auto-wire dependencies in a web application by registering handler functions with the container and letting it inject services based on type hints.
- Manage expensive-to-create singleton instances (database connections, caches) by registering them once and reusing across the application.
- Gradually introduce dependency injection into an existing codebase by adding type hints to constructors without refactoring the rest of the code.
- Build testable code by swapping real dependencies with mocks in test containers without modifying production classes.
- Structure async Python applications where coroutines need injected dependencies resolved at startup.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Lagom is a solid choice for projects needing lightweight dependency injection without framework overhead. Zero runtime dependencies, active maintenance, broad Python version support, and a permissive MIT license make it low-risk. The type-hint-based design integrates well with modern Python tooling. Best suited for teams comfortable with type annotations and seeking minimal configuration; not necessary for very small scripts but valuable for any structured application.
Install
lagom on PyPI
Before you install
Low install friction with no runtime dependencies. Actively maintained with a recent release (394 days ago) and ongoing commits; supports Python 3.7 through 3.13.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
Quickstart
pip install lagom
from lagom import Container
class MyDataSource:
pass
class SomeClass:
def __init__(self, datasource: MyDataSource):
self.datasource = datasource
container = Container()
instance = container[SomeClass]
Verify before relying
- Performance characteristics and overhead compared to manual dependency management or other DI frameworks.
- Scope of framework integrations beyond the mentioned web framework hooks.
- Thread-safety guarantees under concurrent container access patterns.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 394 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 338,072 / month, #7,439 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTyping :: Typed |
Evidence: lagom-2.7.7-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “auto-wiring dependencies”
- lagomLagom is a lightweight dependency injection container that auto-wires…
- pyproject-dependenciesExtracts and prints the direct dependencies declared in Python…
- snowpark-connect-deps-2Provides JAR dependencies for Snowpark Connect, bundling Scala,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Libraries packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.
Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
See also dependency-injector · wireup · in-n-out · kink · rodi · simple-di · injector · dependencies · slack · alluka