Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types #2822

Draft
wants to merge 52 commits into
base: master
Choose a base branch
from
Draft

Add types #2822

wants to merge 52 commits into from

Conversation

last-partizan
Copy link
Contributor

@last-partizan last-partizan commented Jul 9, 2024

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
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant