malthe commented on PR #10587:
URL: https://github.com/apache/airflow/pull/10587#issuecomment-1147120508

   If the `@dag` decorator directly created the DAG instance, this wouldn't be 
a side-effect – it would still just bind the value to a key in the scope (which 
typically is the module globals).
   
   The DAG loading mechanism just looks at the module globals to discover DAGs.
   
   But it's true that the current behavior allows you to pass arguments to 
potentially customize the DAG – but how frequently is that used? If you really 
need this then why not just create a factory function:
   ```python
   def my_dag_factory(arg1):
       with DAG(...) as dag:
           ...
       return dag
   
   dag1 = my_dag_factory(42)
   ```
   (Or use `@dag` instead of `with` for the same effect.)


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