potiuk commented on a change in pull request #7517: [AIRFLOW-6817] Lazy-load `airflow.DAG` to keep user-facing API untouched URL: https://github.com/apache/airflow/pull/7517#discussion_r383309104
########## File path: airflow/__init__.py ########## @@ -42,3 +42,22 @@ login: Optional[Callable] = None integrate_plugins() + +__all__ = ['__version__', 'login', 'DAG'] + + +def __getattr__(name): + # PEP-562: Lazy loaded attributes on python modules + if name == "DAG": + from airflow.models.dag import DAG # pylint: disable=redefined-outer-name Review comment: Let's see and disable it if we find we need it. I am not 100% sure -> the algorithm is quite a bit different than python import mechanism (otherwise we would not have the cyclic imports issue at all). ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
