Skip to content

has_faststream_depends

faststream.broker.fastapi.get_dependant.has_faststream_depends #

has_faststream_depends(orig_call)

Check if faststream.Depends is used in the handler.

Source code in faststream/broker/fastapi/get_dependant.py
def has_faststream_depends(orig_call: Callable[..., Any]) -> bool:
    """Check if faststream.Depends is used in the handler."""
    endpoint_signature = get_typed_signature(orig_call)
    signature_params = endpoint_signature.parameters
    for param in signature_params.values():
        ann = param.annotation
        if ann is not inspect.Signature.empty and get_origin(ann) is Annotated:
            annotated_args = get_args(ann)
            for arg in annotated_args:
                if isinstance(arg, model.Depends):
                    return True
        if isinstance(param.default, model.Depends):
            return True
    return False