jason810496 commented on code in PR #69311:
URL: https://github.com/apache/airflow/pull/69311#discussion_r3519318294


##########
airflow-core/src/airflow/partition_mappers/fixed_key.py:
##########
@@ -46,20 +43,26 @@ class FixedKeyMapper(PartitionMapper):
     :raises ValueError: if *downstream_key* is not a non-empty ``str``.
     """
 
-    downstream_key: str = attrs.field()
+    downstream_key: str
 
-    @downstream_key.validator
-    def _validate_downstream_key(self, attribute: attrs.Attribute, value: str) 
-> None:
-        if not isinstance(value, str) or value == "":
-            raise ValueError(f"FixedKeyMapper downstream_key must be a 
non-empty str; got {value!r}.")
+    def __init__(self, downstream_key: str, *, max_downstream_keys: int | None 
= None) -> None:
+        if not downstream_key or not isinstance(downstream_key, str):
+            raise ValueError(
+                f"FixedKeyMapper downstream_key must be a non-empty str; got 
{downstream_key!r}."
+            )

Review Comment:
   How about adding negative test case for the ValueError branch here as 
follow-up?



##########
airflow-core/src/airflow/partition_mappers/fixed_key.py:
##########
@@ -46,20 +43,26 @@ class FixedKeyMapper(PartitionMapper):
     :raises ValueError: if *downstream_key* is not a non-empty ``str``.
     """
 
-    downstream_key: str = attrs.field()
+    downstream_key: str
 
-    @downstream_key.validator
-    def _validate_downstream_key(self, attribute: attrs.Attribute, value: str) 
-> None:
-        if not isinstance(value, str) or value == "":
-            raise ValueError(f"FixedKeyMapper downstream_key must be a 
non-empty str; got {value!r}.")
+    def __init__(self, downstream_key: str, *, max_downstream_keys: int | None 
= None) -> None:
+        if not downstream_key or not isinstance(downstream_key, str):

Review Comment:
   small nit: Though we _won't_ get None or bool here in most of case.
   
   ```suggestion
           if not isinstance(downstream_key, str) or not downstream_key:
   ```
   
   Please feel free to ignore if not necessary.



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