This is an automated email from the ASF dual-hosted git repository.
shahar pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 4da35b5766 Adjust typing in Mongo hook to prevent mypy errors (#42354)
4da35b5766 is described below
commit 4da35b5766adfd5a60ae924100673e8756e3b24c
Author: Jens Scheffler <[email protected]>
AuthorDate: Thu Sep 19 23:00:12 2024 +0200
Adjust typing in Mongo hook to prevent mypy errors (#42354)
---
airflow/providers/mongo/hooks/mongo.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/airflow/providers/mongo/hooks/mongo.py
b/airflow/providers/mongo/hooks/mongo.py
index 90798d71ce..63b981df9e 100644
--- a/airflow/providers/mongo/hooks/mongo.py
+++ b/airflow/providers/mongo/hooks/mongo.py
@@ -32,6 +32,8 @@ from airflow.hooks.base import BaseHook
if TYPE_CHECKING:
from types import TracebackType
+ from pymongo.collection import Collection as MongoCollection
+ from pymongo.command_cursor import CommandCursor
from typing_extensions import Literal
from airflow.models import Connection
@@ -218,9 +220,7 @@ class MongoHook(BaseHook):
path = f"/{self.connection.schema}"
return urlunsplit((scheme, netloc, path, "", ""))
- def get_collection(
- self, mongo_collection: str, mongo_db: str | None = None
- ) -> pymongo.collection.Collection:
+ def get_collection(self, mongo_collection: str, mongo_db: str | None =
None) -> MongoCollection:
"""
Fetch a mongo collection object for querying.
@@ -233,7 +233,7 @@ class MongoHook(BaseHook):
def aggregate(
self, mongo_collection: str, aggregate_query: list, mongo_db: str |
None = None, **kwargs
- ) -> pymongo.command_cursor.CommandCursor:
+ ) -> CommandCursor:
"""
Run an aggregation pipeline and returns the results.