You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My goal is to wrap Documents to expose a clean and fully typed interface, but the find_one method feels completely messy: why is it not always awaitable? And in what circumstances can it be called without being awaitable?
Can I wrap the find_one method to include the # type: ignore pragma in one place (until #1050 is done), so it is always async?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In the documentation here's how find_one is being used:
[Finding single documents)[https://beanie-odm.dev/tutorial/finding-documents/#finding-single-documents]
But when I look at the API documentation it is not explicitely awaitable:
But when you dig the source code, you see that the FindOne class is actually implementing the
__await__
method:So it is actually awaitable!
Buuuuut… In documents.py there are some calls that are not awaited:
My goal is to wrap Documents to expose a clean and fully typed interface, but the find_one method feels completely messy: why is it not always awaitable? And in what circumstances can it be called without being awaitable?
Can I wrap the
find_one
method to include the# type: ignore
pragma in one place (until #1050 is done), so it is always async?Beta Was this translation helpful? Give feedback.
All reactions