di

class litestar.di.Provide[原始碼]

基底類別:object

Wrapper class for dependency injection

__init__(dependency: AnyCallable | type[Any], use_cache: bool = False, sync_to_thread: bool | None = None) None[原始碼]

初始化 Provide

參數:
  • dependency -- Callable to call or class to instantiate. The result is then injected as a dependency.

  • use_cache -- Cache the dependency return value. Defaults to False.

  • sync_to_thread -- Run sync code in an async thread. Defaults to False.

async __call__(**kwargs: Any) Any[原始碼]

Call the provider's dependency.