Skip to main content

A wrapper around FastAPI's Depends function that infers its return type from its input

Project description

FastAPI inferring Depends

PyPI version GitHub license PyPI - Downloads Tests

A wrapper around FastAPI's Depends function that infers its return type from its input

Example

from fastapi_inferring_depends import Depends
from fastapi import FastAPI

router = FastAPI()


async def answer_to_everything_dependency():
    return 42


@app.get("/answer")
async def get_answer_to_everything(
    answer_to_everything=Depends(answer_to_everything_dependency),
):
    # type of answer_to_everything is 'int' (inferred from dependency)
    return {"answer": answer_to_everything}

For more examples, look at the test/example file for all supported inferences.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_inferring_depends-1.0.0.post1.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page