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

[GitHub] [airflow] o-nikolas commented on a diff in pull request #29523: Fix import cycle starting from airflow/__main__.py

o-nikolas commented on code in PR #29523:
URL: https://github.com/apache/airflow/pull/29523#discussion_r1106325155


##########
airflow/__main__.py:
##########
@@ -24,12 +24,21 @@
 
 import argcomplete
 
+# The configuration module initializes and validates the conf object as a side effect the first
+# time it is imported. If it is not imported before importing the settings module, the conf
+# object will then be initted/validated as a side effect of it being imported in settings,
+# however this can cause issues since those modules are very tightly coupled and can
+# very easily cause import cycles in the conf init/validate code (since downstream code from
+# those functions likely import settings).
+# Therefore importing configuration early (as the first airflow import) avoids
+# any possible import cycles with settings downstream.
+from airflow import configuration

Review Comment:
   It was making ruff upset doing it that way. Using `from airflow import ...` allows it to be the first import in the list without linters being angry.



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