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
| Name | Type | Description |
|---|---|---|
| param_name | str | The name of the parameter to be assigned to the dependant. |
| type_annotation | Any | The type annotation of the parameter, used to determine which attribute of the dependant should be updated. |
| dependant | Dependant | The Dependant object to which the parameter name will be assigned. |
Returns
| Type | Description |
|---|---|
| `bool | None` |