INNER CODE UNIT · Python

register_app

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

async def register_app(app: FastAPI) -> None:
    """Register the given FastAPI app for constructing fake request later."""
    global _app  # noqa: PLW0603
    async with _app_lock:
        _app = app


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):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…