nailo2c commented on code in PR #50518:
URL: https://github.com/apache/airflow/pull/50518#discussion_r2096948058


##########
providers/mongo/src/airflow/providers/mongo/hooks/mongo.py:
##########
@@ -225,6 +225,39 @@ def get_collection(self, mongo_collection: str, mongo_db: 
str | None = None) ->
 
         return 
mongo_conn.get_database(mongo_db).get_collection(mongo_collection)
 
+    def create_collection(
+        self,
+        mongo_collection: str,
+        mongo_db: str | None = None,
+        create_if_exists: bool = True,
+        **create_kwargs: dict[str, Any],

Review Comment:
   Can't narrow it further. `create_collection()` accepts kwargs like 
`read_preference: Optional[_ServerMode]`, `write_concern: 
Optional[WriteConcern]`, `read_concern: Optional[ReadConcern]`, etc. 
   
   So without `Any`, linter will complain about missing types.
   
   Here are the errors I encountered when I assigned the type as 
`CodecOptions[Never] | None`.
   
   ```bash
   providers/mongo/src/airflow/providers/mongo/hooks/mongo.py:253: error: 
Argument
   2 to "create_collection" of "Database" has incompatible type
   "**dict[str, Optional[CodecOptions[NoReturn]]]"; expected
   "Optional[_ServerMode]"  [arg-type]
                   db.create_collection(mongo_collection, **create_kwargs)
                                                            ^~~~~~~~~~~~~
   providers/mongo/src/airflow/providers/mongo/hooks/mongo.py:253: error: 
Argument
   2 to "create_collection" of "Database" has incompatible type
   "**dict[str, Optional[CodecOptions[NoReturn]]]"; expected
   "Optional[WriteConcern]"  [arg-type]
                   db.create_collection(mongo_collection, **create_kwargs)
                                                            ^~~~~~~~~~~~~
   providers/mongo/src/airflow/providers/mongo/hooks/mongo.py:253: error: 
Argument
   2 to "create_collection" of "Database" has incompatible type
   "**dict[str, Optional[CodecOptions[NoReturn]]]"; expected
   "Optional[ReadConcern]"  [arg-type]
                   db.create_collection(mongo_collection, **create_kwargs)
                                                            ^~~~~~~~~~~~~
   providers/mongo/src/airflow/providers/mongo/hooks/mongo.py:253: error: 
Argument
   2 to "create_collection" of "Database" has incompatible type
   "**dict[str, Optional[CodecOptions[NoReturn]]]"; expected
   "Optional[ClientSession]"  [arg-type]
                   db.create_collection(mongo_collection, **create_kwargs)
                                                            ^~~~~~~~~~~~~
   providers/mongo/src/airflow/providers/mongo/hooks/mongo.py:253: error: 
Argument
   2 to "create_collection" of "Database" has incompatible type
   "**dict[str, Optional[CodecOptions[NoReturn]]]"; expected "Optional[bool]" 
   [arg-type]
                   db.create_collection(mongo_collection, **create_kwargs)
                                                            ^~~~~~~~~~~~~
   Found 5 errors in 1 file (checked 1 source file)
   Error 1 returned
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to