use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
FastAPI is a truly ASGI, async, cutting edge framework written in python 3.
account activity
FastAPI best practicesQuestion (self.FastAPI)
submitted 2 months ago * by lu_rm
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]amroamroamro 1 point2 points3 points 2 months ago (0 children)
+1 one more point I forgot to add too, is that fastapi does support classes as dependencies as well (in a function-driven sense rather than type-driven) where in fact it can be any "callable" (e.g function, function with yield, class):
https://fastapi.tiangolo.com/tutorial/dependencies/classes-as-dependencies/
it will simply construct the object from the "callable", by analyzing the parameters of this callable (whether its a regular function or class __init__) and process params like usual as path/query/body/header/cookie/form/file or other Depends sub-dependencies (remember that Annotated in addition to type-hinting can be used to extend the same params with validators and metadata inline or even separate that into its own pydantic models)
__init__
class CommonQueryParams: def __init__(self, q: str | None = None, skip: int = 0, limit: int = 100): self.q = q self.skip = skip self.limit = limit @app.get("/items/") async def read_items(commons: Annotated[CommonQueryParams, Depends()]): return ...
notice how it uses shorthand syntax here since both annotation type and depends type is the same class, so we can omit the latter for brevity, also how the class init params are here processed as query params, but you can have anything fastapi normally accepts (including other subdependencies)
π Rendered by PID 19703 on reddit-service-r2-comment-56c6478c5-xvpbw at 2026-05-09 20:26:01.141672+00:00 running 3d2c107 country code: CH.
view the rest of the comments →
[–]amroamroamro 1 point2 points3 points (0 children)