Taragolis commented on code in PR #38366:
URL: https://github.com/apache/airflow/pull/38366#discussion_r1533830918


##########
airflow/operators/python.py:
##########
@@ -900,16 +900,15 @@ def _external_airflow_version_script(self):
         On the other hand, `importlib.metadata.version` will retrieve the 
package version pretty fast
         something below 100ms; this includes new subprocess overhead.
 
-        Possible side effect: it might be a situation that backport package is 
not available
-        in Python 3.8 and below, which indicates that venv doesn't contain an 
`apache-airflow`
+        Possible side effect: It might be a situation that 
`importlib.metadata` is not available (Python < 3.8),
+        as well as backport `importlib_metadata` which might indicate that 
venv doesn't contain an `apache-airflow`
         or something wrong with the environment.
         """
         return textwrap.dedent(
             """
-            import sys
-            if sys.version_info >= (3, 9):
+            try:
                 from importlib.metadata import version
-            else:
+            except ImportError:
                 from importlib_metadata import version
             print(version("apache-airflow"))

Review Comment:
   I kept `importlib_metadata` in detect airflow version in venv.
   In theory it should use the same version of Airflow, and this is Core 
Operator.
   So it pretty safe to use `version` from stdlib `importlib.metadata`
   
   Because if it can't found, that might indicate that user use some old 
version of Python 3.7/3.6 and other ancients, this also unlikely it could 
install same version of Airflow in such environment which is limited by 3.8



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