skillfed

kink

Dependency injection for python.

kink v0.9.0 132.7K downloads/30d#11,539 on PyPI444
Permissive license MIT Active released

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 kink

uv

uv add kink

poetry

poetry add kink

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

dependency injection container pythonautowiring dependency resolverinversion of control containerservice locator patternpython di frameworkautomatic dependency resolutiondecorator-based injection
dependency-injectioninversion-of-controlautowiring

More Libraries packages