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.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file fastapi_inferring_depends-1.0.0.tar.gz.

File metadata

File hashes

Hashes for fastapi_inferring_depends-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2c30d9222339ac5cd46ded8e6b95ae18e314970abd916e30dbfd37f2037e6943
MD5 49e42229f3cc72e1d213590f40a9b580
BLAKE2b-256 51e13a5c984b1c8bcd12bd1705b484d6b0352bea90313f613422d07e4f008635

See more details on using hashes here.

File details

Details for the file fastapi_inferring_depends-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_inferring_depends-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70cea2928455e0deabf720a2a97621c5a29cb7f930189e85d3e9a3aa90145aaf
MD5 5d344e0b8e7e6005474790502d26d980
BLAKE2b-256 8fc98b6ee08f40fe3caef79565c6b4325127403ad5cdb673334dd5423ee765e8

See more details on using hashes here.

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