Skip to main content

add_non_field_param_to_dependency

Adds a non-field parameter to a dependency by setting the appropriate parameter name on the Dependant object based on the parameter's type annotation. It returns True if a matching type is found and the parameter name is set, otherwise None.

def add_non_field_param_to_dependency(
param_name: str,
type_annotation: Any,
dependant: Dependant
) - > bool | None

Assigns a non-field parameter to a Dependant object based on its type annotation. This function is used to correctly associate special FastAPI/Starlette parameters (like Request, Response, WebSocket) with the dependency that requires them.

Parameters

NameTypeDescription
param_namestrThe name of the parameter to be assigned to the dependant.
type_annotationAnyThe type annotation of the parameter, used to determine which attribute of the dependant should be updated.
dependantDependantThe Dependant object to which the parameter name will be assigned.

Returns

TypeDescription
`boolNone`