BeanieODM / beanie

Asynchronous Python ODM for MongoDB
http://beanie-odm.dev/
Apache License 2.0
2.02k stars 213 forks source link

improving and fix type hint #907

Closed CAPITAINMARVEL closed 6 months ago

CAPITAINMARVEL commented 6 months ago

to be continued ...

CAPITAINMARVEL commented 6 months ago

@roman-right apologise for the other pull request deleted i dont know well github 😅 I think for the type hint it works well only issue that im trying to fix is the type hint for the update things its a bit confusing cause it need to be awaited or else it doesnt update anything in database.

However currently it wont warn the user about it if the user forget to await it, it will say on print something like <beanie.odm.queries.find.FindOne object at 0x0000024B194D52B0> But if we forget await a function python normal it would say RuntimeWarning: coroutine 'testa' was never awaited self._context.run(self._callback, *self._args) RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Cause for type hint it can be fixed using overload and async

CAPITAINMARVEL commented 6 months ago

which can lead to error to the user so I dont know what should be done to fix that

bedlamzd commented 6 months ago

@CAPITAINMARVEL did you just copy my pull request #886 and not even changed a thing in the commit? huh...