--- id: dishka version: "1.10.1" license: Apache-2.0 license_treatment: permissive maintenance: active --- # dishka — Cute DI framework with scopes and agreeable API License: permissive · Maintenance: active · Downloads: 636.6K/mo ## What it is and what it does dishka is a dependency injection container that solves the problem of passing objects through layers of constructors by centralizing dependency creation and lifecycle management. It lets you define providers that specify how to create dependencies, assign them to scopes (app-wide, per-request, or custom), and automatically handle resource cleanup when scopes end. The library focuses narrowly on DI without mixing in configuration, logging, or other concerns. You define your classes with type hints, create providers that specify factories and scopes, combine them into a container, and then retrieve dependencies through the container. Higher-scoped dependencies (like app-level singletons) are accessible from lower scopes (like request-level), and finalization hooks let you close database connections or release other resources when a scope ends. It supports multiple Python versions from 3.10 onward and integrates with popular web frameworks. Use it for: - Web application request handling: create app-level singletons (database pools, config) and request-level instances (services, DAOs) with automatic cleanup. - Modular service architecture: split dependency factories into reusable provider classes instead of monolithic configuration. - Resource management: define cleanup logic (e.g., closing connections) alongside creation, ensuring resources are released when scopes exit. - Testing: swap real implementations for mocks by providing alternate providers without changing application code. - Multi-scope applications: manage dependencies with custom lifetimes beyond just app and request (e.g., per-user, per-transaction). - Framework integration: use built-in middleware or decorators to wire dishka into FastAPI, Starlette, or other supported frameworks. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. dishka is an IoC container that manages dependency injection with support for multiple scopes and resource finalization, letting you define how and when dependencies are created and released. Yes. dishka is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a real problem—managing complex object graphs without global state or scattered markers. It's a good fit if you're building a modular application with multiple dependency scopes or need resource finalization. Not necessary for small scripts or projects with simple, flat dependencies. ## Install pip install dishka uv add dishka poetry add dishka ## Installing dishka Before you install: Low friction: pure Python wheel with a single runtime dependency (exceptiongroup). Active maintenance with recent releases; repository shows 1241 stars and last commit on 2026-08-14. License in practice: Apache-2.0 permissive license allows commercial and private use with minimal restrictions, making it suitable for most projects. Quickstart: pip install dishka from dishka import Provider, Scope, make_container, provide provider = Provider(scope=Scope.APP) provider.provide(MyService) container = make_container(provider) service = container.get(MyService) container.close() Requires Python 3.10 or later. Verify before relying: - Performance comparison claims against other DI frameworks—fact sheet notes it 'outperforms many alternatives' but provides no benchmarks. - Specific framework integrations supported beyond the documentation reference—which frameworks are 'out of the box'. - Whether finalization (cleanup on scope exit) works reliably with all dependency types or has known limitations. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 636.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags dependency injection container, IoC container Python, scoped dependency management, resource finalization DI, factory pattern framework, application lifecycle management, modular provider pattern, dependency-injection, ioc-container, scope-management [View on SkillFed](https://skillfed.io/packages/dishka) · [View on PyPI](https://pypi.org/project/dishka/)