Skip to main content

Depends

This class defines a dependency injection provider used to declare requirements for path operations and other dependencies. It allows for the specification of a callable dependency, control over result caching, and the definition of the dependency's lifecycle scope.

Attributes

AttributeTypeDescription
dependency`Callable[..., Any]None` = None
use_cachebool = TrueDetermines whether the result of the dependency should be cached and reused within the same request scope.
scope`Literal["function", "request"]None` = None

Constructor

Signature

def Depends(
dependency: Callable[..., Any]| None = None,
use_cache: bool = True,
scope: Literal["function", "request"]| None = None
) - > null

Parameters

NameTypeDescription
dependency`Callable[..., Any]None` = None
use_cachebool = TrueDetermines whether the result of the dependency should be cached for the duration of the request.
scope`Literal["function", "request"]None` = None

Signature

def Depends(
dependency: Callable[..., Any]| None = None,
use_cache: bool = True,
scope: Literal["function", "request"]| None = None
) - > null

Parameters

NameTypeDescription
dependency`Callable[..., Any]None` = None
use_cachebool = TrueDetermines whether the result of the dependency should be cached and reused within the same request scope.
scope`Literal["function", "request"]None` = None