iamai.dependencies module#

iamai 依赖注入。

实现依赖注入相关功能。

iamai.dependencies.Depends(dependency: Type[_T | AsyncContextManager[_T] | ContextManager[_T]] | Callable[[], AsyncGenerator[_T, None]] | Callable[[], Generator[_T, None, None]] | None = None, *, use_cache: bool = True) _T[source]#

子依赖装饰器。

Parameters:
  • dependency – 依赖类。如果不指定则根据字段的类型注释自动判断。

  • use_cache – 是否使用缓存。默认为 True

Returns:

返回内部子依赖对象。