kaxil commented on code in PR #43738:
URL: https://github.com/apache/airflow/pull/43738#discussion_r1831560451


##########
tests_common/pytest_plugin.py:
##########
@@ -50,6 +50,23 @@
 
     Op = TypeVar("Op", bound=BaseOperator)
 
+# NOTE: DO NOT IMPORT AIRFLOW THINGS HERE!
+#
+# This plugin is responsible for configuring Airflow correctly to run tests.
+# Importing Airflow here loads Airflow too eagerly and break the 
configurations.
+# Instead, import what you want lazily inside a fixture function.
+#
+# Be aware that many things in tests_common also indirectly imports Airflow, so
+# those modules also should not be imported globally.
+#
+# (Things in the TYPE_CHECKING block are fine because they are not actually
+# imported at runtime; those imports are only hints to the type checker.)
+
+assert "airflow" not in sys.modules, (
+    "Airflow SHOULD NOT have been imported at this point! "
+    "Read comments in pytest_plugin.py to understand more."

Review Comment:
   🤞 



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