Skip to content

Commit 75aef8e

Browse files
committed
Update type ignores
1 parent 8075dad commit 75aef8e

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

pymongo/asynchronous/bulk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ def add_insert(self, document: _DocumentOut) -> None:
133133
validate_is_document_type("document", document)
134134
# Generate ObjectId client side.
135135
if not (isinstance(document, RawBSONDocument) or "_id" in document):
136-
new_document = {"_id": ObjectId()} | document # type: ignore[index]
137-
document.clear()
138-
document.update(new_document)
136+
new_document = {"_id": ObjectId()} | document # type: ignore[index, operator]
137+
document.clear() # type: ignore[attr-defined]
138+
document.update(new_document) # type: ignore[attr-defined]
139139
self.ops.append((_INSERT, document))
140140

141141
def add_update(

pymongo/asynchronous/client_bulk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ def add_insert(self, namespace: str, document: _DocumentOut) -> None:
133133
validate_is_document_type("document", document)
134134
# Generate ObjectId client side.
135135
if not (isinstance(document, RawBSONDocument) or "_id" in document):
136-
new_document = {"_id": ObjectId()} | document # type: ignore[index]
137-
document.clear()
138-
document.update(new_document)
136+
new_document = {"_id": ObjectId()} | document # type: ignore[index, operator]
137+
document.clear() # type: ignore[attr-defined]
138+
document.update(new_document) # type: ignore[attr-defined]
139139
cmd = {"insert": -1, "document": document}
140140
self.ops.append(("insert", cmd))
141141
self.namespaces.append(namespace)

pymongo/asynchronous/collection.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -885,9 +885,9 @@ async def insert_one(
885885
"""
886886
common.validate_is_document_type("document", document)
887887
if not (isinstance(document, RawBSONDocument) or "_id" in document):
888-
new_document = {"_id": ObjectId()} | document # type: ignore[index]
889-
document.clear()
890-
document.update(new_document)
888+
new_document = {"_id": ObjectId()} | document # type: ignore[index, operator]
889+
document.clear() # type: ignore[attr-defined]
890+
document.update(new_document) # type: ignore[attr-defined]
891891

892892
write_concern = self._write_concern_for(session)
893893
return InsertOneResult(
@@ -968,9 +968,9 @@ def gen() -> Iterator[tuple[int, Mapping[str, Any]]]:
968968
common.validate_is_document_type("document", document)
969969
if not isinstance(document, RawBSONDocument):
970970
if "_id" not in document:
971-
new_document = {"_id": ObjectId()} | document # type: ignore[index]
972-
document.clear()
973-
document.update(new_document)
971+
new_document = {"_id": ObjectId()} | document # type: ignore[index, operator]
972+
document.clear() # type: ignore[attr-defined]
973+
document.update(new_document) # type: ignore[attr-defined]
974974
inserted_ids.append(document["_id"])
975975
yield (message._INSERT, document)
976976

pymongo/synchronous/bulk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ def add_insert(self, document: _DocumentOut) -> None:
133133
validate_is_document_type("document", document)
134134
# Generate ObjectId client side.
135135
if not (isinstance(document, RawBSONDocument) or "_id" in document):
136-
new_document = {"_id": ObjectId()} | document # type: ignore[index]
137-
document.clear()
138-
document.update(new_document)
136+
new_document = {"_id": ObjectId()} | document # type: ignore[index, operator]
137+
document.clear() # type: ignore[attr-defined]
138+
document.update(new_document) # type: ignore[attr-defined]
139139
self.ops.append((_INSERT, document))
140140

141141
def add_update(

pymongo/synchronous/client_bulk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ def add_insert(self, namespace: str, document: _DocumentOut) -> None:
133133
validate_is_document_type("document", document)
134134
# Generate ObjectId client side.
135135
if not (isinstance(document, RawBSONDocument) or "_id" in document):
136-
new_document = {"_id": ObjectId()} | document # type: ignore[index]
137-
document.clear()
138-
document.update(new_document)
136+
new_document = {"_id": ObjectId()} | document # type: ignore[index, operator]
137+
document.clear() # type: ignore[attr-defined]
138+
document.update(new_document) # type: ignore[attr-defined]
139139
cmd = {"insert": -1, "document": document}
140140
self.ops.append(("insert", cmd))
141141
self.namespaces.append(namespace)

pymongo/synchronous/collection.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,9 @@ def insert_one(
884884
"""
885885
common.validate_is_document_type("document", document)
886886
if not (isinstance(document, RawBSONDocument) or "_id" in document):
887-
new_document = {"_id": ObjectId()} | document # type: ignore[index]
888-
document.clear()
889-
document.update(new_document)
887+
new_document = {"_id": ObjectId()} | document # type: ignore[index, operator]
888+
document.clear() # type: ignore[attr-defined]
889+
document.update(new_document) # type: ignore[attr-defined]
890890

891891
write_concern = self._write_concern_for(session)
892892
return InsertOneResult(
@@ -967,9 +967,9 @@ def gen() -> Iterator[tuple[int, Mapping[str, Any]]]:
967967
common.validate_is_document_type("document", document)
968968
if not isinstance(document, RawBSONDocument):
969969
if "_id" not in document:
970-
new_document = {"_id": ObjectId()} | document # type: ignore[index]
971-
document.clear()
972-
document.update(new_document)
970+
new_document = {"_id": ObjectId()} | document # type: ignore[index, operator]
971+
document.clear() # type: ignore[attr-defined]
972+
document.update(new_document) # type: ignore[attr-defined]
973973
inserted_ids.append(document["_id"])
974974
yield (message._INSERT, document)
975975

0 commit comments

Comments
 (0)