o-nikolas commented on a change in pull request #19665:
URL: https://github.com/apache/airflow/pull/19665#discussion_r754589627



##########
File path: airflow/providers/amazon/aws/sensors/redshift.py
##########
@@ -43,7 +43,10 @@ def __init__(
     ):
         super().__init__(**kwargs)
         self.cluster_identifier = cluster_identifier
-        self.target_status = target_status
+        self.target_status = (
+            target_status if isinstance(target_status, ClusterStates) else 
ClusterStates(str(target_status))
+        )
+
         self.aws_conn_id = aws_conn_id
         self.hook: Optional[RedshiftHook] = None
 

Review comment:
       Note:
   The logging on line 54 below isn't going to look like it did before now that 
it's an Enum. Adding `.value` to the Enum will create the same log.
   ```python
   In [16]: from enum import Enum                                               
                                         
   
   In [17]: class ClusterStates(Enum): 
       ...:     """Contains the possible State values of a Redshift Cluster.""" 
       ...:     AVAILABLE = 'available' 
       ...:     CREATING = 'creating' 
       ...:                                                                     
                                         
   
   In [18]: target_state = ClusterStates.AVAILABLE                              
                                         
   
   In [19]: print('looking for %s state' % target_state)                        
                                         
   looking for ClusterStates.AVAILABLE state
   
   In [20]: print('looking for %s state' % target_state.value)                  
                                         
   looking for available state
   
   In [21]:  
   ```
   
   But perhaps it's actually better leaving it as is so that the logging makes 
it clear that it's an Enum? I don't feel strongly one way or another actually. 
What do you think?:
   




-- 
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: [email protected]

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


Reply via email to