casassg commented on PR #10587:
URL: https://github.com/apache/airflow/pull/10587#issuecomment-1147896755
There is a non-python side-effect there which is that the decorated function
would require to be called on the module import level. Aka:
```py
@dag(...)
def my_dag(...):
raise Exception("fail")
```
would raise and exception as in order to build the DAG it will need to call
the dag. This can lead to confusing behaviour, as the code is being executed
even though its declared inside a function and the function has not been
called. In Python you expect function code to not be executed until the
function is called.
Effectively, @dag decorator is thought as a DAG factory more than a dag
declaration mechanism.
--
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]