You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
There is a slight fundamental difference between typing in pymongo and this package. Namely, many pymongo classes are generic on the document type. See pymongo.MongoClient as the main example. The client is created with the document_class keyword argument which defaults to dict. This allows methods like Collection.find_one to be very specific about their return type (e.g. if the collection belongs to a client where the document class is dict, then the return type of Collection.find_one is dict[str, Any]).
For what it's worth, I never use anything other than dict as the document class in either package and I find the constant need for defining everything to be generic on the document class to be quite cumbersome. Nevertheless, I thought I would create this issue to hopefully spark a discussion around the topic 😄
The text was updated successfully, but these errors were encountered:
Since you mentioned this one, if you were to see that I made a _Document instead of directly plugging in a dict, it was intended for that very purpose. Unfortunately in actual runtime, doing something like MotorClient[...] was producing errors as these classes don't support generics themselves. So either we get a monkey patch or we wait for the og repo to add generics in the classes. Then we can simply add the typevars and generic[_doc] and we good!
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Thanks again for the stubs!
There is a slight fundamental difference between typing in
pymongo
and this package. Namely, manypymongo
classes are generic on the document type. See pymongo.MongoClient as the main example. The client is created with thedocument_class
keyword argument which defaults todict
. This allows methods likeCollection.find_one
to be very specific about their return type (e.g. if the collection belongs to a client where the document class isdict
, then the return type ofCollection.find_one
isdict[str, Any]
).Currently, this package is set up to always return
_Document = typing.Mapping[str, typing.Any]
(https://github.com/L0RD-ZER0/Motor-Types/blob/8ffaa4fb9c0e9e93ef0425ea761b47d0502b1d87/motor-stubs/core.pyi#L31C1-L31C44). While this behavior is not incorrect per se, it does present a major development experience difference between the two packages (and after all,motor
is built to very closely mirrorpymongo
).For what it's worth, I never use anything other than
dict
as the document class in either package and I find the constant need for defining everything to be generic on the document class to be quite cumbersome. Nevertheless, I thought I would create this issue to hopefully spark a discussion around the topic 😄The text was updated successfully, but these errors were encountered: