You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/02/13 04:02:21 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #29436: Handle `multiple_outputs` inferral with TYPE_CHECKING

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


##########
airflow/decorators/base.py:
##########
@@ -299,6 +299,12 @@ def _infer_multiple_outputs(self):
             return_type = typing_extensions.get_type_hints(self.function).get("return", Any)
         except TypeError:  # Can't evaluate return type.
             return False
+        except NameError:  # A typing import is not defined; probably behind TYPE_CHECKING.
+            return_type = self.function.__annotations__.get("return", Any)
+            # If using PEP 563, the return annotation value is stringified. Need to transform to a type to
+            # properly check against dict type.
+            if isinstance(return_type, str):
+                return_type = eval(return_type)

Review Comment:
   I think this could still raise NameError in some cases. Maybe we should return False as a last resort instead of failing?



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