Skip to main content

add_non_field_param_to_dependency

Assigns a parameter name to a specific attribute of a Dependant object based on whether the type annotation matches known system types like Request, WebSocket, or Response. Returns True if a match is found and the state is updated, otherwise returns None.

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

Assigns a parameter name to a specific attribute on a Dependant object based on its type annotation. This is used to map special request-related types like Request, Response, or BackgroundTasks to the correct internal dependency handler.

Parameters

NameTypeDescription
param_namestrThe name of the parameter as defined in the function signature.
type_annotationAnyThe type hint or class used to determine which specific dependency attribute should be populated.
dependantDependantThe dependency model object that will store the mapping for later injection.

Returns

TypeDescription
`boolnull`