kaxil commented on a change in pull request #10025:
URL: https://github.com/apache/airflow/pull/10025#discussion_r462270321



##########
File path: airflow/providers/amazon/aws/sensors/athena.py
##########
@@ -49,20 +50,20 @@ class AthenaSensor(BaseSensorOperator):
 
     @apply_defaults
     def __init__(self,
-                 query_execution_id,
-                 max_retires=None,
-                 aws_conn_id='aws_default',
-                 sleep_time=10,
-                 *args, **kwargs):
+                 query_execution_id: str,
+                 max_retires: Optional[int] = None,
+                 aws_conn_id: str = 'aws_default',
+                 sleep_time: int = 10,
+                 *args: Any, **kwargs: Any) -> None:
         super().__init__(*args, **kwargs)
         self.aws_conn_id = aws_conn_id
         self.query_execution_id = query_execution_id
         self.sleep_time = sleep_time
         self.max_retires = max_retires
-        self.hook = None
+        self.hook = self.get_hook()

Review comment:
       This should be None bye default to avoid initializing hooks in Operators 
init.
   
   Otherwise, whenever the scheduler parses the DAG files, DB calls are made to 
the database.
   
   You could do the following to fix mypy errors:
   
   ```suggestion
           self.hook: Optional[AWSAthenaHook] = None
   ```

##########
File path: airflow/providers/amazon/aws/operators/athena.py
##########
@@ -73,19 +82,17 @@ def __init__(  # pylint: disable=too-many-arguments
         self.result_configuration = result_configuration or {}
         self.sleep_time = sleep_time
         self.max_tries = max_tries
-        self.query_execution_id = None
-        self.hook = None
+        self.query_execution_id = None  # type: Optional[str]
+        self.hook = self.get_hook()

Review comment:
       This should be None bye default to avoid initializing hooks in Operators 
init.
   
   Otherwise, whenever the scheduler parses the DAG files, DB calls are made to 
the database.
   
   You could do the following to fix mypy errors:
   
   ```suggestion
           self.hook: Optional[AWSAthenaHook] = None
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to