API

Reference

QuartModule

class quart_injector.QuartModule(app)

Bases: Module

Quart module.

Parameters:

app (Quart) – quart application

configure(binder)

Override to configure bindings.

Parameters:

binder (Binder) –

Return type:

None

request

quart_injector.request(cls: injector.T) injector.T = ScopeDecorator(RequestScope)

A decorator for quart_injector.RequestScope.

Parameters:

cls (T) –

Return type:

T

RequestScope

class quart_injector.RequestScope(injector)

Bases: Scope

Request scope

A Scope that returns a per-request instance for a key.

Parameters:

injector (Injector) –

configure()

Configure the scope.

Return type:

None

get(key, provider)

Get a Provider for a key.

Parameters:
  • key (type[~T]) – The key to return a provider for.

  • provider (Provider[T]) – The default Provider associated with the key.

Returns:

A Provider instance that can provide an instance of key.

Return type:

Provider[T]

pop()

Remove topmost item from stack.

Return type:

None

push()

Push new item onto stack.

Return type:

None

wire

quart_injector.wire(app, modules=None, auto_bind=True, parent=None)

Wire.

Wire up a dependency injection container to the given application.

Parameters:
  • app (Quart) – quart application

  • modules (Callable[[Binder], None] | Module | Type[Module] | Iterable[Callable[[Binder], None] | Module | Type[Module]] | None) – configuration module or iterable of configuration modules

  • auto_bind (bool) – whether to automatically bind missing types

  • parent (Injector | None) – dependency injection container

Return type:

None

wrap

quart_injector.wrap(view_func, app, container)

Wrap

Wrap the given view function for dependency injection.

Parameters:
  • view_func (Callable) – view function or class based view

  • app (Quart) – quart application

  • container (Injector) – dependency injection container

Returns:

wrapped view function

Return type:

Callable