A wrapper around FastAPI's Depends function that infers its return type from its input
Project description
FastAPI inferring Depends
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fastapi_inferring_depends-1.0.0.post1.tar.gz
.
File metadata
- Download URL: fastapi_inferring_depends-1.0.0.post1.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c24e8a87971934559e692e8559cb2e76be976578c613473d4f50dcedb5e60cf7 |
|
MD5 | 9577b5dc5deadbdea46a0f852b634f62 |
|
BLAKE2b-256 | f57d4389678da308871611729578f6f99b7d3583f4b738ba8da701bddf670c45 |
File details
Details for the file fastapi_inferring_depends-1.0.0.post1-py3-none-any.whl
.
File metadata
- Download URL: fastapi_inferring_depends-1.0.0.post1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f47a86493149c1178440e0369605feef1fe6d193c004e432dc28e15449e21be |
|
MD5 | 38474d832146d610f12118d27275bcfe |
|
BLAKE2b-256 | 02df14d1649aef6e1a85098ebf8e080f992a35a0d3085ff00d14368681e73167 |