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:11:04 UTC

[GitHub] [airflow] turbaszek commented on a change in pull request #10349: infer multiple_output from return type annotation

turbaszek commented on a change in pull request #10349:
URL: https://github.com/apache/airflow/pull/10349#discussion_r471062528



##########
File path: airflow/operators/python.py
##########
@@ -276,6 +276,16 @@ def task(
     :type multiple_outputs: bool
 
     """
+
+    if python_callable:
+        sig = signature(python_callable).return_annotation
+        ttype = getattr(sig, "__origin__", None)
+        if (
+            sig != inspect.Signature.empty
+            and (ttype in (dict, Dict, tuple, Tuple))

Review comment:
       ```suggestion
               and ttype in (dict, Dict, tuple, Tuple))
   ```
   I would say that we should only check for `(tuple, Tuple)` because that's the only indicator of multiple output. For example:
   ```
   def x() -> Dict[str, str]:
       return {"a": "b", "c": "d'}
   ```
   is a single output function in my opinion.
   WDYT? @casassg @evgenyshulman @jonathanshir 
   




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