Quart adapter¶
pip install pydepi-quart — import as depi_quart. Usage guide:
Quart integration.
QuartInjector
¶
QuartInjector(provider: ServiceProvider, param_name: str = 'provider', autowire: bool = False)
Bases: BaseInjector
Per-request dependency scopes for a Quart app.
Example
injector = QuartInjector(provider, param_name='container') injector.setup(app)
@app.route('/data/
inject uses functools.wraps, so it composes inside a decorator stack --
route registration, auth, response handling -- without the outer layers
losing the view function's identity.
Parameters:
-
provider(ServiceProvider) –the built ServiceProvider to resolve from.
-
param_name(str, default:'provider') –the keyword argument the request scope is passed as in the default (non-autowire) mode. Name it to taste --
containeris a common alternative. -
autowire(bool, default:False) –when True,
injectresolves registered types by annotation instead of passing the scope. Not supported by every integration; FastAPI rejects it outright.
Source code in packages/depi-core/depi/integration.py
setup
¶
Install before/teardown request hooks on app.
Source code in packages/depi-quart/depi_quart/__init__.py
create_scope
¶
create_scope() -> ServiceScope
current_scope
¶
current_scope() -> ServiceScope
Return the scope bound to the current request context.
Raises:
-
NoActiveScopeError–if setup(app) never ran, or this is called outside a request.
Source code in packages/depi-core/depi/integration.py
inject
¶
Decorator handing the request scope to fn.
Default mode passes the scope as the param_name keyword argument.
With autowire=True, parameters annotated with registered types are
resolved and passed individually instead.
Uses functools.wraps, so it composes inside a decorator stack (route registration, auth, response handling) without losing the wrapped function's identity.