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 2020/08/16 04:45:17 UTC

[GitHub] [airflow] turbaszek edited a comment on pull request #10349: infer multiple_output from return type annotation

turbaszek edited a comment on pull request #10349:
URL: https://github.com/apache/airflow/pull/10349#issuecomment-674477268


   Thanks @AndersonReyes for taking interest in this issue! This looks good but we need to adjust this logic of XCom storage:
   https://github.com/apache/airflow/blob/382c1011b6bcebd22760e2f98419281ef1a09d1b/airflow/operators/python.py#L243-L254
   
   Also the crucial part of this change is allowing users to reference those returned values before executing a task. For example this should work:
   ```python
   @task
   def task1() -> Tuple[str, int]:
       return "magic", 42
   
   
   @task 
   def task2(a: str, b: int) -> None:
       pass
   
   
   a, b = task1()
   task2(a, b)
   ```
   
   And this means that we have to implement some smart `__iter__` for `XComArg` class because that's the return type of `task1()` invocation.  Otherwise we get this:
   ```
       a, b = task2()
   ValueError: too many values to unpack (expected 2)
   ```
   
   
   


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

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