kink
Dependency injection for python.
What it is and what it does
Kink is a dependency injection container that manages object creation and dependency resolution for Python applications. It allows you to register services (either eagerly or on-demand) in a central container and then automatically inject them into classes and functions via the @inject decorator. The container supports both name-based and type-annotation-based dependency matching, with a clear priority system: manually passed arguments override name matches, which override type annotations.
The package solves the problem of tightly coupled code by letting you define dependencies externally rather than hardcoding them. It supports factories (services created fresh on each request), lazy initialization via lambdas, and async operations. With only typing_extensions as a dependency, it integrates cleanly into modern Python projects supporting versions 3.8 through 3.14.
Use it for:
- Bootstrap configuration and database connections at startup, then inject them throughout your application without passing through signatures.
- Build testable class hierarchies by injecting mock implementations in tests while using real implementations in production.
- Create plugin or factory patterns where the container automatically instantiates the correct implementation based on type annotations.
- Manage async service initialization and lifecycle in asyncio-based applications without manual state management.
- Reduce boilerplate in multi-layer applications by letting the container wire dependencies automatically.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Kink is a lightweight dependency injection container for Python that automatically resolves and injects dependencies into classes and functions using decorators and type annotations.
Yes. Kink is a solid choice for Python projects that want dependency injection without heavyweight frameworks. It has low install friction, active maintenance, no known vulnerabilities, a permissive MIT license, and broad Python version support. Use it when you want to decouple components and improve testability without adopting a full web framework.
Install
kink on PyPI
pip
pip install kinkuv
uv add kinkpoetry
poetry add kinkInstalling kink
Before you install
Installation is straightforward with low friction—a pure Python wheel with only typing_extensions as a runtime dependency. The project is actively maintained with a recent release on 2026-03-19 and shows healthy repository signals.
License in practice
MIT license is permissive, allowing free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install kink
from kink import di, inject
from typing_extensions import Annotated
di["config"] = {"db": "test.db"}
di["db_connection"] = lambda di: f"Connection to {di['config']['db']}"
@inject
class UserService:
def __init__(self, db_connection: str):
self.db = db_connection
service = di[UserService]
print(service.db)
Verify before relying
- Whether async/await support works with all Python versions listed (3.8–3.14) or has version-specific limitations
- Performance characteristics when managing large numbers of services or deeply nested dependency graphs
- How custom dependency resolvers integrate with the autowiring mechanism in practice
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing_extensions |
| Maintenance | actively maintained — 148 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 132,726/month — #11,539 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: kink-0.9.0-py3-none-any.whl
Keywords: kink, dependency injection
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
injectorInjector is a Python dependency injection…
permissive · top 5,000 on PyPI
dishkadishka is an IoC container that manages…
permissive · top 15,000 on PyPI
simple-diA strictly typed dependency injection library…
permissive · top 15,000 on PyPI
slackA dependency injection container that registers…
permissive · top 15,000 on PyPI
lagomLagom is a lightweight dependency injection…
permissive · top 15,000 on PyPI
punqPunq is a dependency injection container for…
unclear · top 15,000 on PyPI
allukaAlluka is a type-based dependency injection…
permissive · top 15,000 on PyPI
dependency-injectorDependency Injector is a dependency injection…
permissive · top 5,000 on PyPI
dependenciesImplements constructor injection for dependency…
permissive · top 15,000 on PyPI
wireupWireup is a type-driven dependency injection…
permissive · top 15,000 on PyPI