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


##########
airflow/operators/python.py:
##########
@@ -450,6 +451,12 @@ def __init__(
             raise ValueError(f"{type(self).__name__} only supports functions 
for python_callable arg")
         if inspect.isgeneratorfunction(python_callable):
             raise ValueError(f"{type(self).__name__} does not support using 
'yield' in python_callable")
+        if env_vars:
+            for key, value in env_vars.items():
+                if not isinstance(key, str):
+                    raise ValueError(f"env_vars key ${key} must be a string, 
but got {type(key)}")
+                if not isinstance(value, str):
+                    raise ValueError(f"env_vars value must be a string, but 
got {type(value)}")

Review Comment:
   As a general rule, argument validation should be done in `execute` instead, 
to accomodate possible user customisation such as policy rules.
   
   I kind of feel we don’t actually need to do these checks at all since 
non-string values will cause execution to eventually fail anyway.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to