Install & Compatibility
Where this runs
tested against v1.10.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.9
✕ build_error
✕ build_error
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Provider
✓ from dishka import Provider
Scope
✓ from dishka import Scope
provide
✓ from dishka import provide
inject
✓ from dishka import inject
make_container
✓ from dishka import make_container
This quickstart demonstrates how to define dependencies using `Provider` and `provide`, manage scopes (`Scope.APP`, `Scope.REQUEST`) with `make_container`, and retrieve services. Dependencies are automatically resolved based on type hints.
import asyncio
from dishka import Provider, Scope, provide, make_container
class MyDependency:
def __init__(self, name: str):
self.name = name
class MyService:
def __init__(self, dep: MyDependency):
self.dep = dep
class MyProvider(Provider):
@provide(scope=Scope.APP)
def get_dependency(self) -> MyDependency:
return MyDependency(name="Global Dep")
@provide(scope=Scope.REQUEST)
def get_service(self, dep: MyDependency) -> MyService:
return MyService(dep)
async def main():
# 1. Create a container with your providers
container = make_container(MyProvider())
# 2. Enter an application scope
async with container(scope=Scope.APP) as app_container:
# 3. Enter a request scope (or other child scope)
async with app_container(scope=Scope.REQUEST) as request_container:
# 4. Get a dependency from the current scope
service = await request_container.get(MyService)
print(f"Service created with dependency name: {service.dep.name}")
await container.close()
if __name__ == "__main__":
asyncio.run(main())
Errors
Common errors & fixes
TypeError: object is not a Provider
A class intended to define dependencies does not inherit from `dishka.Provider`.
fixEnsure your dependency provider class inherits from `dishka.Provider`, e.g., `class MyProvider(Provider):`.
dishka.exceptions.InvalidDependencyGraphError: Cannot find dependency for MyService
The requested type (e.g., `MyService`) or one of its dependencies cannot be found in the registered providers, or there's a circular dependency.
fixVerify that all types required by `MyService` (and `MyService` itself) are provided by a `@provide` decorated method in your `Provider`s, and check for circular dependencies.
ModuleNotFoundError: No module named 'dishka.integrations.fastapi'
You are attempting to use a Dishka integration (e.g., for FastAPI) without installing the necessary extra package.
fixInstall Dishka with the required extra: `pip install dishka[fastapi]` (replace `fastapi` with your desired integration).
dishka.exceptions.ScopeExitError: Cannot exit scope REQUEST: it is not the current active scope.
You are trying to exit a container scope that is not the most recently entered or active scope, often due to mismatched `async with` blocks.
fixEnsure that container scopes are entered and exited in the correct LIFO (Last-In, First-Out) order, typically by nesting `async with container(scope=...)` blocks correctly.
Upgrade
Version history
1.10.1latest on PyPI · released Apr 25, 2026
Audit
Dependencies
fastapioptionalOptional integration with FastAPI
aiogramoptionalOptional integration with AioGram
litestaroptionalOptional integration with Litestar
faststreamoptionalOptional integration with FastStream
starliteoptionalOptional integration with Starlite
taskiqoptionalOptional integration with Taskiq
arqoptionalOptional integration with ARQ