-
Notifications
You must be signed in to change notification settings - Fork 210
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
MOTOR-1285 Add generics to type stubs #272
Conversation
Hi @Doekeb, thanks for adding this! Out of curiosity, were you wanting to use this feature yourself, or did you want to add this for completeness with the PyMongo API? Also, can you please add a test similar to this one in PyMongo? Of note, we are planning to release 3.4 either tomorrow or the next day. |
Thanks for taking a look! I'm definitely interested in using it myself, but I do think it's quite nice to have parity with PyMongo. My use case is a data access API layer where both PyMongo and Motor are used (PyMongo for everyday use, e.g. fetch some data in a notebook and put it into a pandas DataFrame, and Motor mainly for listening to a change stream). It's nice to be able to have parallel definitions everywhere. Also, making everything generic on the document type allows one to be more sure about the nature of returned documents (e.g. you can do more things with a I probably won't have a chance to implement those test for at least the next couple of days, but I'm happy to do so when I get a chance! |
Okay, sounds good! We'll save it for the 3.5 release then, which will most likely coincide with PyMongo 4.7. |
Just added those tests, ready for another look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much!
This PR adds generics to type stubs to match
pymongo
. For example,MongoClient
is generic on its_DocumentType
. This PR makesAgnosticClient
,AsyncIOMotorClient
, andMotorClient
also generic on the same_DocumentType
(as well as all the other classes where the correspondingpymongo
class is generic, includingDatabase
,Collection
,ChangeStream
, and the variousCursor
s).