potiuk commented on code in PR #43773:
URL: https://github.com/apache/airflow/pull/43773#discussion_r1867669213


##########
providers/src/airflow/providers/common/compat/__init__.py:
##########
@@ -23,17 +23,21 @@
 #
 from __future__ import annotations
 
-import packaging.version
+from packaging.version import Version
 
-from airflow import __version__ as airflow_version
+from airflow import __version__ as AIRFLOW_VERSION
 
 __all__ = ["__version__"]
 
 __version__ = "1.2.2"
 
-if 
packaging.version.parse(packaging.version.parse(airflow_version).base_version) 
< packaging.version.parse(
-    "2.8.0"
-):
+
+AIRFLOW_V_3_0_PLUS = Version(Version(AIRFLOW_VERSION).base_version) >= 
Version("3.0.0")
+AIRFLOW_V_2_10_PLUS = Version(Version(AIRFLOW_VERSION).base_version) >= 
Version("2.10.0")
+AIRFLOW_V_2_9_PLUS = Version(Version(AIRFLOW_VERSION).base_version) >= 
Version("2.9.0")
+AIRFLOW_V_2_8_PLUS = Version(Version(AIRFLOW_VERSION).base_version) >= 
Version("2.8.0")
+
+if not AIRFLOW_V_2_8_PLUS:
     raise RuntimeError(
         f"The package `apache-airflow-providers-common-compat:{__version__}` 
needs Apache Airflow 2.8.0+"

Review Comment:
   Agree. Plus - as discussed in slack 
https://apache-airflow.slack.com/archives/C06K9Q5G2UA/p1733228100524949 we 
should aalso not reuse the same constant names for those versions in providers, 
they are used and defined in `tests_common` and it's very easy to confuse them.
   
   my proposal will be to:
   * use `TEST_AIRFLOW_V` in tests 
   * add those constants `AIRFLOW_V`` to common.compat in "versions" package 
(not in `__init__.py`)
   * bump min version of common for all providers to make sure all of them have 
it
   
   That should solve the problem permanently and in a few places where some 
providers already use their own constants - we could use them from 
`common.compat` (for example here 
https://github.com/apache/airflow/blob/main/providers/src/airflow/providers/amazon/aws/assets/s3.py#L40)
 
   
   WDYT @uranusjr @dstandish @eladkal ? Does it sound good? 



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