https://github.com/jvllmr/fastapi-inferring-depends
A wrapper around FastAPI's Depends function that infers its return type from its input
https://github.com/jvllmr/fastapi-inferring-depends
Last synced: 3 months ago
JSON representation
A wrapper around FastAPI's Depends function that infers its return type from its input
- Host: GitHub
- URL: https://github.com/jvllmr/fastapi-inferring-depends
- Owner: jvllmr
- License: mit
- Created: 2023-05-27T17:28:19.000Z (about 2 years ago)
- Default Branch: dev
- Last Pushed: 2025-04-01T06:01:25.000Z (3 months ago)
- Last Synced: 2025-04-01T07:21:39.488Z (3 months ago)
- Language: Python
- Homepage:
- Size: 139 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastAPI inferring Depends
[](https://badge.fury.io/py/fastapi-inferring-depends)
[](https://github.com/jvllmr/fastapi-inferring-depends/blob/master/LICENSE)

A wrapper around FastAPI's Depends function that infers its return type from its input
## Example
```python
from fastapi_inferring_depends import Depends
from fastapi import FastAPIapp = 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](https://github.com/jvllmr/fastapi-inferring-depends/blob/dev/test_example.py) for all supported inferences.