potiuk commented on code in PR #44686: URL: https://github.com/apache/airflow/pull/44686#discussion_r1874570467
########## providers/src/airflow/providers/edge/version_compat.py: ########## @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# NOTE! THIS FILE IS COPIED MANUALLY IN OTHER PROVIDERS DELIBERATELY TO AVOID ADDING UNNECESSARY +# DEPENDENCIES BETWEEN PROVIDERS. IF YOU WANT TO ADD CONDITIONAL CODE IN YOUR PROVIDER THAT DEPENDS +# ON AIRFLOW VERSION, PLEASE COPY THIS FILE TO THE ROOT PACKAGE OF YOUR PROVIDER AND IMPORT +# THOSE CONSTANTS FROM IT RATHER THAN IMPORTING THEM FROM ANOTHER PROVIDER OR TEST CODE +# + +from __future__ import annotations + +from packaging.version import Version + + +def _get_base_airflow_version() -> Version: + from airflow import __version__ + + return Version(Version(__version__).base_version) Review Comment: We do .. This is the main reason why we need to discuss all of that at all. The whole reason why we do this weird `Version(Version.base_version)` is because default comparision rules do not work properly for pre-release version and if we do not do it, checking for features available will break with pre-relase versions. I explained it earlier today in https://lists.apache.org/thread/h0s7ypdr05j10jw88b3svj57o4ml1brl - also there is this discussion in PyPI that explains why we have to do it https://github.com/pypa/pip/issues/13089 Basically it's because of this paragraph in PEP-440: > Within a numeric release (1.0, 2.7.3), the following suffixes are permitted and MUST be ordered as shown: > .devN, aN, bN, rcN, <no suffix>, .postN This paragraph in PEP 440 and it's implementation in `packaging` means that we have to do this weird looking double version retrieval, because in order to check "is feature available in this version" - we need to basically drop pre-release part of the version (which `Version(Version(__version__).base_version)` does. -- 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]
