sbdchd / mongo-types

:fallen_leaf: Type stubs for mongoengine, pymongo, and bson
Apache License 2.0
19 stars 8 forks source link

Go/missing typing #32

Closed GlennOlsson closed 3 years ago

GlennOlsson commented 3 years ago

Add missing typing for register_connection and EnumField according to API for register_connection and the source for EnumField

GlennOlsson commented 3 years ago

Thanks for the feedback!

I added a field in the tests as you mentioned but am getting an error I cannot wrap my head around, the same found in the CircleCI log. Not sure why the db_field is being set by the Enum parameter at all, do you have any idea why? I have tried removing the db_field from the EnumField initialisers but the same error appears, meaning that it is not derived from my code but probably from the mongoengine or pymongo library would be my guess. Have you encountered this before or have any tips?

sbdchd commented 3 years ago

There were a couple issues, one is that pyright doesn't like overloads via __init__ but for some reason those are working for other fields. In this case we overload __new__ so that both pyright and mypy are happy.

After fixing that pyright and mypy complained about some overlapping overloads so I updated them to using a required keyword args via *, which allows us to avoid having them as default ... which was causing the overlap.

GlennOlsson commented 3 years ago

Alright, thanks a lot!