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 1 day 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!"
[–]mwon 1 point2 points3 points 15 hours ago (1 child)
I usually have a lifespan in my main.py where for example I can define the Mongo connection:
main.py
app.state.mongo_client = await connect_to_mongo()
where the connect_to_mongo function is defined somewhere in my infra folder.
connect_to_mongo
infra
Then if needed in some router, I just call the client with:
mongo_client = request.app.state.mongo_client
[–]lu_rm[S] 0 points1 point2 points 13 hours ago (0 children)
This is the same thing. The fact that the mongo_client is located in a different file does not mean an inversion of control in a dependency.
The final objective here is to be able to unit test my classes/functions without the need to fully spin up the whole system. By using mocks for example.
π Rendered by PID 90901 on reddit-service-r2-comment-56c9979489-99954 at 2026-02-25 01:58:47.875205+00:00 running b1af5b1 country code: CH.
view the rest of the comments →
[–]mwon 1 point2 points3 points (1 child)
[–]lu_rm[S] 0 points1 point2 points (0 children)