turbaszek commented on a change in pull request #14400:
URL: https://github.com/apache/airflow/pull/14400#discussion_r581362910
##########
File path: airflow/upgrade/rules/fix_conf_not_importable_from_airflow.py
##########
@@ -0,0 +1,29 @@
+
+from airflow.upgrade.rules.base_rule import BaseRule
+
+print(BaseRule)
+
+<<<<<<< HEAD
+
+class ConfImportFromAirflow(BaseRule):
+ """
+ ConfImportFromAirflow class to ensure proper import of conf from to work
in Airflow 2.0
+ """
+ title = "Properly import conf from Airflow"
+ description = """\
+ In Airflow-2.0, it's not possible to import conf from airflow by using
\'import conf from airflow\'
+ To ensure your code works in Airflow 2.0, you should use \'from
airflow.Configuration import conf \'
+ """
+
+ def check(self):
+ from airflow import conf
+ if conf:
+ return (
+ "Warning: Properly import conf to ensure your code works in
AIrflow 2.0"
+ "From Airflow 2.0, you should use from airflow.Configuration
import conf."
+ )
Review comment:
What this rule should do is to scan all users DAGs and plugins and
verify if they use `from airflow import conf` in their code. If yes, we should
raise a warning for each file that is impacted by this issue.
Here's an example how can we iterate through DAG files:
https://github.com/apache/airflow/blob/dbf2e302313580b6eaa85e9fcbcace8b6260c85a/airflow/upgrade/rules/import_changes.py#L138-L146
Same can be done for plugins using ` plugins_folder = conf.get("core",
"plugins_folder")`.
----------------------------------------------------------------
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]