mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

Add types

Open last-partizan opened this issue 1 year ago • 3 comments

This PR adds types.

Partially, from https://github.com/sbdchd/mongo-types/ by @sbdchd Partially, generated by monkeytype Partially handwritten and generated by included gen.py script (i'll remove it before merging)

I inlined most of the types, but fieds require lot of @overloads - so i put that into separate .pyi.

Note to self, check:

  • [ ] Passing generic types to fields when using string (like ReferenceField[Image]('Image'))

last-partizan avatar Jul 09 '24 17:07 last-partizan

@bagerard And now i need some guidance.

How to best approach testing types? For start i just put some tests into 'tests/test_typing.yml`, but running these tests requires mypy and all optional dependencies.

And that's probably will be slowest tests, due to mypy being not so fast.

pytest tests/test_typing.yml  18.11s user 0.98s system 99% cpu 19.144 total

If speed is a priority, we can put this into separate folder and run once on single python version. But, we can also run this on all supported python versions (greater than 3.9) - this is probably better, but slower option.

last-partizan avatar Jul 09 '24 17:07 last-partizan

great work 🦸🏽

jokester avatar Dec 01 '24 11:12 jokester

@bagerard this is ready for review.

That one CI fail looks like unrelated to my changes.

But, maybe it's time to drop 3.8 and 3.7 from CI and add 3.12 and 13? I can handle this in separate PR if you wish.

last-partizan avatar Dec 01 '24 13:12 last-partizan