potix2 commented on a change in pull request #11531:
URL: https://github.com/apache/airflow/pull/11531#discussion_r505805235



##########
File path: airflow/providers/amazon/aws/operators/datasync.py
##########
@@ -165,27 +166,29 @@ def __init__(
             )
 
         # Others
-        self.hook = None
+        self.hook: Optional[AWSDataSyncHook] = None
         # Candidates - these are found in AWS as possible things
         # for us to use
-        self.candidate_source_location_arns = None
-        self.candidate_destination_location_arns = None
-        self.candidate_task_arns = None
+        self.candidate_source_location_arns: Optional[List[str]] = None
+        self.candidate_destination_location_arns: Optional[List[str]] = None
+        self.candidate_task_arns: Optional[List[str]] = None
         # Actuals
-        self.source_location_arn = None
-        self.destination_location_arn = None
-        self.task_execution_arn = None
+        self.source_location_arn: Optional[str] = None
+        self.destination_location_arn: Optional[str] = None
+        self.task_execution_arn: Optional[str] = None
 
-    def get_hook(self):
+    def get_hook(self) -> AWSDataSyncHook:
         """Create and return AWSDataSyncHook.
 
         :return AWSDataSyncHook: An AWSDataSyncHook instance.
         """
-        if not self.hook:

Review comment:
       `self.hook` is initialized by `None` so its type is 
`Optional[AWSDataSyncHook]`. To eliminate the possibility that `get_hook` 
returns `None`, we need to rearrange the order of evaluation.




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