From 9aa4feb443309021b4d279bcc2a44e52af45257d Mon Sep 17 00:00:00 2001 From: MezentsevIlya Date: Wed, 7 Feb 2024 23:59:30 +0500 Subject: [PATCH 1/2] Change docs type in insert_many to list of dicts --- airflow/providers/mongo/hooks/mongo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/providers/mongo/hooks/mongo.py b/airflow/providers/mongo/hooks/mongo.py index 857bbc312ff6f..3b1ea5e36d641 100644 --- a/airflow/providers/mongo/hooks/mongo.py +++ b/airflow/providers/mongo/hooks/mongo.py @@ -210,7 +210,7 @@ def insert_one( return collection.insert_one(doc, **kwargs) def insert_many( - self, mongo_collection: str, docs: dict, mongo_db: str | None = None, **kwargs + self, mongo_collection: str, docs: list[dict], mongo_db: str | None = None, **kwargs ) -> pymongo.results.InsertManyResult: """ Inserts many docs into a mongo collection. From ceda588872d71c15eb25c2d81f30c509f26839d5 Mon Sep 17 00:00:00 2001 From: MezentsevIlya Date: Thu, 8 Feb 2024 12:33:12 +0500 Subject: [PATCH 2/2] Change list to Iterable --- airflow/providers/mongo/hooks/mongo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airflow/providers/mongo/hooks/mongo.py b/airflow/providers/mongo/hooks/mongo.py index 3b1ea5e36d641..934312a638e44 100644 --- a/airflow/providers/mongo/hooks/mongo.py +++ b/airflow/providers/mongo/hooks/mongo.py @@ -20,7 +20,7 @@ import warnings from ssl import CERT_NONE -from typing import TYPE_CHECKING, Any, overload +from typing import TYPE_CHECKING, Any, Iterable, overload from urllib.parse import quote_plus, urlunsplit import pymongo @@ -210,7 +210,7 @@ def insert_one( return collection.insert_one(doc, **kwargs) def insert_many( - self, mongo_collection: str, docs: list[dict], mongo_db: str | None = None, **kwargs + self, mongo_collection: str, docs: Iterable[dict], mongo_db: str | None = None, **kwargs ) -> pymongo.results.InsertManyResult: """ Inserts many docs into a mongo collection.