INNER CODE UNIT · Python

_get_app

JasperSui/fastapi-injectable · src/fastapi_injectable/main.py:83

def _get_app() -> FastAPI | None:
    """Get the registered FastAPI app."""
    return _app


def _has_depends(param: inspect.Parameter) -> bool:
    """Check if a parameter has a Depends() annotation (either via Annotated metadata or as default)."""
    # Check Annotated[Type, Depends(...)] style
    if get_origin(param.annotation) is Annotated:
        for metadata in get_args(param.annotation)[1:]:
            if isinstance(metadata, fastapi.params.Depends):
                return True
    # Check default=Depends(...) style
    return isinstance(param.default, fastapi.params.Depends)


def _build_dependency_only_callable(
    func: Callable[..., Any],

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…