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/06/28 04:06:55 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #24667: Clean up task decorator type hints and docstrings

uranusjr commented on code in PR #24667:
URL: https://github.com/apache/airflow/pull/24667#discussion_r908009505


##########
airflow/decorators/__init__.pyi:
##########
@@ -124,20 +124,14 @@ class TaskDecoratorCollection:
     @overload
     def virtualenv(self, python_callable: Function) -> Task[Function]: ...
     @overload
-    def branch(
-        self, python_callable: Optional[Callable] = None, multiple_outputs: Optional[bool] = None, **kwargs
-    ) -> TaskDecorator:
-        """Wraps a python function into a BranchPythonOperator
+    def branch(self, *, multiple_outputs: Optional[bool] = None, **kwargs) -> TaskDecorator:

Review Comment:
   The real implementation is intended to be used with two variants:
   
   ```python
   @task.branch
   def func(**context):
       ...
   
   @task.branch(**kwargs)
   def func(**context):
       ...
   ```
   
   The first variant accepts exactly one positional argument `python_callable`. The second should not accept `python_callable`, but all the other arguments (normally as keywords, although theoratically you could do `@task.branch(None, True, ...)`). This type hint better reflects the intention, not the actual implementation details.



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