mongoengine
mongoengine copied to clipboard
Typing support
Hi folks
Are you interested in adding types to your project?
There is https://github.com/sbdchd/mongo-types project, but it's incomplete and outdated. But types can be integrated back into the original project.
If you're interested, i can try making a PR.
This is a great idea but it all depends how much it will clutter this codebase. Although MongoEngine is way less complex and popular, it is worth mentioning this post from django on the same topic https://github.com/django/deps/pull/65
I recently started testing mongo-types and fixed a bunch of issues, of course the dynamic nature of Documents, some Fields and Querysets makes typing quite tricky to get right, you may want to check it out here https://github.com/bagerard/mongo-types. I also see that the original project received some commits recently.
Alternative could be to get mongo-types under the MongoEngine umbrella, but as a separate library
I started working on this, and it was going fine until i got to fields.
To account for required parameter we need to do overloads, and writing so much overloads is not fun. django-stubs has mypy plugin for this, and in theory we can also make a plugin. But it will work only for mypy obviously.
But, what if mypy plugin was able to export it's generated types into pyi, for other type checkers to consume? I created an issue for mypy, and hoping for the best: https://github.com/python/mypy/issues/17315
In the meantime, i'm thinking about writing some sort of script that will generate all those overrides, but for now it's only cool idea in my head.
https://github.com/last-partizan/mongoengine/tree/merge-stubs
PR: #2822