kaxil commented on code in PR #53387: URL: https://github.com/apache/airflow/pull/53387#discussion_r2215536412
########## airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py: ########## @@ -21,7 +21,12 @@ from pydantic import BaseModel -from airflow.utils.state import DagRunState +from airflow.version_compat import AIRFLOW_V_3_1_PLUS + +if AIRFLOW_V_3_1_PLUS: + from airflow.sdk.definitions.state import DagRunState +else: + from airflow.utils.state import DagRunState # type: ignore[no-redef] Review Comment: This approach has a fundamental **circular dependency problem**. You cannot check for version compatibility within the same package you're checking for: ```python from airflow import __version__ # Importing airflow's version from within airflow itself AIRFLOW_V_3_1_PLUS = get_base_airflow_version_tuple() >= (3, 1, 0) ``` This is like asking "Am I myself?" to decide who you are - it's a logical impossibility. When airflow-core imports from `airflow.version_compat`, it's trying to check its own version to decide what to import, which creates a circular reference. Version compatibility checks only make sense when checking for *external* dependencies, not when a package is trying to check its own version for internal import decisions. ########## airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/calendar.py: ########## @@ -21,7 +21,12 @@ from pydantic import BaseModel -from airflow.utils.state import DagRunState +from airflow.version_compat import AIRFLOW_V_3_1_PLUS + +if AIRFLOW_V_3_1_PLUS: + from airflow.sdk.definitions.state import DagRunState +else: + from airflow.utils.state import DagRunState # type: ignore[no-redef] Review Comment: Yeah core should never have that anyway coz you can't check a different version of the X library within the X library itself :) -- 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]
