Taragolis commented on code in PR #34222:
URL: https://github.com/apache/airflow/pull/34222#discussion_r1320374677


##########
airflow/providers/amazon/aws/triggers/rds.py:
##########
@@ -129,16 +130,21 @@ def __init__(
         waiter_max_attempts: int,
         aws_conn_id: str,
         response: dict[str, Any],
-        db_type: RdsDbType,
+        db_type: RdsDbType | str,
         region_name: str | None = None,
     ) -> None:
+        # allow passing enums for users,
+        # but we can only rely on strings because (de-)serialization doesn't 
support enums
+        if isinstance(db_type, RdsDbType):
+            db_type = db_type.value
+
         super().__init__(
             serialized_fields={
                 "db_identifier": db_identifier,
                 "response": response,
                 "db_type": db_type,
             },
-            waiter_name=f"db_{db_type.value}_available",
+            waiter_name=f"db_{db_type}_available",

Review Comment:
   I just want to suggest to extend 
   
https://github.com/apache/airflow/blob/f5c2748c3346bdebf445afd615657af8849345dd/airflow/providers/amazon/aws/utils/__init__.py#L75
   
   To something like:
   
   ```python
   class _StringCompareEnum(Enum):
       # Previous implementation instead of this comment
   
       def __str__(self):
           return self.value
   
       @classmethod
       def from_string(cls, value: str | Enum):
           if not (isinstance(value, str) or isinstance(value, cls)):
               raise TypeError(f"Unable convert {value!r} to {cls!r}.")
           elif isinstance(value, cls):
               return value
   
           values = cls.__members__.values()
           for v in values:
               if v == value:
                   return v
           else:
               raise ValueError(
                   f"Unsupported Enum value for {cls!r}. Expected one of {', 
'.join(repr(v.value) for v in values)}, "
                   f"but got {value!r}."
               )
   ```
   
   Anyway, it just nitpick it could be **entirely ignored** or we could do this 
later or maybe make Enums serialisable in core



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