You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/02/24 08:21:11 UTC

[GitHub] [airflow] dstandish commented on a change in pull request #21754: Rename operator mapping map() to apply()

dstandish commented on a change in pull request #21754:
URL: https://github.com/apache/airflow/pull/21754#discussion_r813640106



##########
File path: airflow/decorators/task_group.py
##########
@@ -106,12 +107,16 @@ def _make_task_group(self, **kwargs) -> MappedTaskGroup:
         return tg
 
     def partial(self, **kwargs) -> "MappedTaskGroupDecorator[R]":
-        if self.partial_kwargs:
-            raise RuntimeError("Already a partial task group")
+        duplicated_keys = [k for k in kwargs if k in self.partial_kwargs]
+        if len(duplicated_keys):

Review comment:
       ```suggestion
           if len(duplicated_keys) == 1:
   ```

##########
File path: airflow/decorators/task_group.py
##########
@@ -106,12 +107,16 @@ def _make_task_group(self, **kwargs) -> MappedTaskGroup:
         return tg
 
     def partial(self, **kwargs) -> "MappedTaskGroupDecorator[R]":
-        if self.partial_kwargs:
-            raise RuntimeError("Already a partial task group")
+        duplicated_keys = [k for k in kwargs if k in self.partial_kwargs]
+        if len(duplicated_keys):
+            raise ValueError(f"Cannot overwrite partial argument: {duplicated_keys[0]!r}")
+        elif duplicated_keys:
+            joined = ", ".join(repr(k) for k in duplicated_keys)
+            raise ValueError(f"Cannot overwrite partial arguments: {joined}")

Review comment:
       or alternatively... 
   
   ```suggestion
   duplicated_keys = [k for k in kwargs if k in self.partial_kwargs]
   if duplicated_keys:
       raise ValueError(f"Cannot overwrite partial arguments: {duplicated_keys!r}")
   ```
   
   personally i wouldn't sweat the grammar but different strokes :) 




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org