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



##########
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:
       Using `self.hook: Optional[AWSAthenaHook] = None` results in:
   ```
   airflow/providers/amazon/aws/operators/athena.py:127: error: Item "None" of
   "Optional[AWSAthenaHook]" has no attribute "stop_query"
                   response = self.hook.stop_query(self.query_execution_id)
   ```

##########
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:
       Using `self.hook: Optional[AWSAthenaHook] = None` results in:
   ```
   airflow/providers/amazon/aws/operators/athena.py:127: error: Item "None" of
   "Optional[AWSAthenaHook]" has no attribute "stop_query"
                   response = self.hook.stop_query(self.query_execution_id)
   ``` from `mypy`

##########
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:
       Using `self.hook: Optional[AWSAthenaHook] = None` results in:
   ```
   airflow/providers/amazon/aws/operators/athena.py:127: error: Item "None" of
   "Optional[AWSAthenaHook]" has no attribute "stop_query"
                   response = self.hook.stop_query(self.query_execution_id)
   ``` 
   from `mypy`

##########
File path: airflow/providers/amazon/aws/sensors/athena.py
##########
@@ -71,8 +72,6 @@ def poke(self, context):
             return False
         return True
 
-    def get_hook(self):
+    def get_hook(self) -> AWSAthenaHook:

Review comment:
       `functools.cached_property` is Python >= 3.8 isn't it?

##########
File path: airflow/providers/amazon/aws/sensors/athena.py
##########
@@ -71,8 +72,6 @@ def poke(self, context):
             return False
         return True
 
-    def get_hook(self):
+    def get_hook(self) -> AWSAthenaHook:

Review comment:
       Ah nvm, I see the pypi pkg `cached-property` is used instead




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