mongo-types
mongo-types copied to clipboard
:fallen_leaf: Type stubs for mongoengine, pymongo, and bson
Steps to reproduce: 1. Create a module that includes the following code: ``` import mongoengine mongoengine.register_connection( alias="core", name="foobar", username="username", password="password", ) connection = mongoengine.get_connection("core") ``` 2. Run mypy against it:...
mypy reports that the port argument for the register_connection() function needs to be either a string or None: ``` Argument "port" to "register_connection" has incompatible type "int"; expected "str |...
`get_database` method in `MongoClient` actually has arguments defined like ```py def get_database( self, name: Optional[str] = None, codec_options: Optional[CodecOptions] = None, read_preference: Optional[_ServerMode] = None, write_concern: Optional[WriteConcern] = None, read_concern:...
As of pymongo 4.3.3 the `Collection.replace_one` method has the `upsert` parameter, but it's missing from the stub definitions: https://github.com/sbdchd/mongo-types/blob/main/pymongo-stubs/collection.pyi#L76 ```python def replace_one( self, filter: Mapping[str, Any], replacement: Mapping[str, Any], bypass_document_validation:...
Error: ```sh (venv) (base) ➜ mypy . test.py:3: error: Module has no attribute "MAX_BSON_SIZE" Found 1 error in 1 file (checked 1 source file) ``` code of pymongo:  https://github.com/mongodb/mongo-python-driver/blob/e6b65860f59b432487fcdb385fde663345ce2917/pymongo/common.py#L56...
``` (nda) Ethans-MacBook-Pro:nda ethan$ pip install mongo-types ERROR: Could not find a version that satisfies the requirement mongo-types (from versions: none) ERROR: No matching distribution found for mongo-types ```
```python class Post: user = fields.ListField(fields.StringField()) post = Post() # should be 'list[str | None] | None' since user is not required and StringField is not required. reveal_type(post.user) # Revealed...
I am currently developing an asynchronous app with `motor` instead of `pymongo` and `mypy`. As far as I know, it's not that different from PyMongo, and, in some places uses...
required=False is the default behavior. We should remove this option to prevent mistakes where callers mistakenly think required=True is the default behavior. The following definitions are equivalent ``` class Post:...