mongo-python-driver/test/mypy_fails/raw_bson_document.py
2022-03-02 13:10:15 -06:00

14 lines
411 B
Python

from bson.raw_bson import RawBSONDocument
from pymongo import MongoClient
client = MongoClient(document_class=RawBSONDocument)
coll = client.test.test
doc = {"my": "doc"}
coll.insert_one(doc)
retreived = coll.find_one({"_id": doc["_id"]})
assert retreived is not None
assert len(retreived.raw) > 0
retreived[
"foo"
] = "bar" # error: Unsupported target for indexed assignment ("RawBSONDocument") [index]