This is an automated email from the ASF dual-hosted git repository.
joshfell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 9c59831ee7 Update providers to use functools compat for
``cached_property`` (#24582)
9c59831ee7 is described below
commit 9c59831ee78f14de96421c74986933c494407afa
Author: Josh Fell <[email protected]>
AuthorDate: Tue Jun 21 22:02:12 2022 -0400
Update providers to use functools compat for ``cached_property`` (#24582)
---
.../providers/alibaba/cloud/log/oss_task_handler.py | 7 +------
airflow/providers/alibaba/cloud/sensors/oss_key.py | 7 +------
airflow/providers/amazon/aws/hooks/glue_crawler.py | 7 +------
airflow/providers/amazon/aws/hooks/quicksight.py | 7 +------
airflow/providers/amazon/aws/hooks/redshift_sql.py | 7 +------
.../amazon/aws/log/cloudwatch_task_handler.py | 7 +------
airflow/providers/amazon/aws/log/s3_task_handler.py | 7 +------
airflow/providers/amazon/aws/operators/athena.py | 7 +------
airflow/providers/amazon/aws/operators/emr.py | 12 ++----------
.../providers/amazon/aws/operators/glue_crawler.py | 8 +-------
.../providers/amazon/aws/operators/redshift_data.py | 8 +-------
airflow/providers/amazon/aws/operators/sagemaker.py | 7 +------
.../providers/amazon/aws/secrets/secrets_manager.py | 8 +-------
.../providers/amazon/aws/secrets/systems_manager.py | 8 +-------
airflow/providers/amazon/aws/sensors/athena.py | 7 +------
.../providers/amazon/aws/sensors/cloud_formation.py | 7 +------
airflow/providers/amazon/aws/sensors/emr.py | 8 +-------
airflow/providers/amazon/aws/sensors/quicksight.py | 7 +------
airflow/providers/amazon/aws/sensors/s3.py | 8 +-------
airflow/providers/asana/hooks/asana.py | 7 +------
.../providers/cncf/kubernetes/hooks/kubernetes.py | 10 ++--------
.../cncf/kubernetes/operators/kubernetes_pod.py | 7 +------
.../providers/databricks/hooks/databricks_base.py | 7 +------
airflow/providers/dbt/cloud/hooks/dbt.py | 7 +------
airflow/providers/facebook/ads/hooks/ads.py | 7 +------
airflow/providers/google/ads/hooks/ads.py | 7 +------
.../cloud/_internal_client/secret_manager_client.py | 11 ++---------
airflow/providers/google/cloud/hooks/automl.py | 21 +++++++--------------
airflow/providers/google/cloud/hooks/compute_ssh.py | 7 +------
airflow/providers/google/cloud/hooks/pubsub.py | 10 ++--------
airflow/providers/google/cloud/hooks/vision.py | 10 ++--------
.../providers/google/cloud/log/gcs_task_handler.py | 10 ++--------
.../google/cloud/log/stackdriver_task_handler.py | 10 ++--------
.../hashicorp/_internal_client/vault_client.py | 8 +-------
.../microsoft/azure/log/wasb_task_handler.py | 7 +------
.../providers/microsoft/azure/secrets/key_vault.py | 10 ++--------
.../microsoft/azure/transfers/sftp_to_wasb.py | 8 +-------
airflow/providers/salesforce/hooks/salesforce.py | 7 +------
airflow/providers/ssh/hooks/ssh.py | 7 +------
39 files changed, 53 insertions(+), 269 deletions(-)
diff --git a/airflow/providers/alibaba/cloud/log/oss_task_handler.py
b/airflow/providers/alibaba/cloud/log/oss_task_handler.py
index 393847f93a..d404a47e4a 100644
--- a/airflow/providers/alibaba/cloud/log/oss_task_handler.py
+++ b/airflow/providers/alibaba/cloud/log/oss_task_handler.py
@@ -18,13 +18,8 @@
import contextlib
import os
import pathlib
-import sys
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
+from airflow.compat.functools import cached_property
from airflow.configuration import conf
from airflow.providers.alibaba.cloud.hooks.oss import OSSHook
from airflow.utils.log.file_task_handler import FileTaskHandler
diff --git a/airflow/providers/alibaba/cloud/sensors/oss_key.py
b/airflow/providers/alibaba/cloud/sensors/oss_key.py
index 0160783178..00e897f5d6 100644
--- a/airflow/providers/alibaba/cloud/sensors/oss_key.py
+++ b/airflow/providers/alibaba/cloud/sensors/oss_key.py
@@ -15,16 +15,11 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import sys
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
from typing import TYPE_CHECKING, Optional, Sequence
from urllib.parse import urlparse
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.providers.alibaba.cloud.hooks.oss import OSSHook
from airflow.sensors.base import BaseSensorOperator
diff --git a/airflow/providers/amazon/aws/hooks/glue_crawler.py
b/airflow/providers/amazon/aws/hooks/glue_crawler.py
index 65f7df8d28..e4138290d1 100644
--- a/airflow/providers/amazon/aws/hooks/glue_crawler.py
+++ b/airflow/providers/amazon/aws/hooks/glue_crawler.py
@@ -15,15 +15,10 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import sys
import warnings
from time import sleep
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
diff --git a/airflow/providers/amazon/aws/hooks/quicksight.py
b/airflow/providers/amazon/aws/hooks/quicksight.py
index a11ad2781b..2058661d0a 100644
--- a/airflow/providers/amazon/aws/hooks/quicksight.py
+++ b/airflow/providers/amazon/aws/hooks/quicksight.py
@@ -16,20 +16,15 @@
# specific language governing permissions and limitations
# under the License.
-import sys
import time
from botocore.exceptions import ClientError
from airflow import AirflowException
+from airflow.compat.functools import cached_property
from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
from airflow.providers.amazon.aws.hooks.sts import StsHook
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
class QuickSightHook(AwsBaseHook):
"""
diff --git a/airflow/providers/amazon/aws/hooks/redshift_sql.py
b/airflow/providers/amazon/aws/hooks/redshift_sql.py
index 03bb45f7ee..692b600b38 100644
--- a/airflow/providers/amazon/aws/hooks/redshift_sql.py
+++ b/airflow/providers/amazon/aws/hooks/redshift_sql.py
@@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-import sys
from typing import Dict, List, Optional, Union
import redshift_connector
@@ -23,13 +22,9 @@ from redshift_connector import Connection as
RedshiftConnection
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
+from airflow.compat.functools import cached_property
from airflow.hooks.dbapi import DbApiHook
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
class RedshiftSQLHook(DbApiHook):
"""
diff --git a/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
b/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
index 7d4f81006b..c13ebd87e8 100644
--- a/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
+++ b/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
@@ -15,17 +15,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import sys
from datetime import datetime
from typing import Optional
import watchtower
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.configuration import conf
from airflow.utils.log.file_task_handler import FileTaskHandler
from airflow.utils.log.logging_mixin import LoggingMixin
diff --git a/airflow/providers/amazon/aws/log/s3_task_handler.py
b/airflow/providers/amazon/aws/log/s3_task_handler.py
index cb8e0a2883..ae12b2ca2f 100644
--- a/airflow/providers/amazon/aws/log/s3_task_handler.py
+++ b/airflow/providers/amazon/aws/log/s3_task_handler.py
@@ -17,14 +17,9 @@
# under the License.
import os
import pathlib
-import sys
from typing import Optional
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.configuration import conf
from airflow.utils.log.file_task_handler import FileTaskHandler
from airflow.utils.log.logging_mixin import LoggingMixin
diff --git a/airflow/providers/amazon/aws/operators/athena.py
b/airflow/providers/amazon/aws/operators/athena.py
index 6febe2a917..b3e3f90889 100644
--- a/airflow/providers/amazon/aws/operators/athena.py
+++ b/airflow/providers/amazon/aws/operators/athena.py
@@ -16,15 +16,10 @@
# specific language governing permissions and limitations
# under the License.
#
-import sys
import warnings
from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.models import BaseOperator
from airflow.providers.amazon.aws.hooks.athena import AthenaHook
diff --git a/airflow/providers/amazon/aws/operators/emr.py
b/airflow/providers/amazon/aws/operators/emr.py
index 77c079be83..dc698c5fd7 100644
--- a/airflow/providers/amazon/aws/operators/emr.py
+++ b/airflow/providers/amazon/aws/operators/emr.py
@@ -16,27 +16,19 @@
# specific language governing permissions and limitations
# under the License.
import ast
-import sys
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union
from uuid import uuid4
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.models import BaseOperator
-from airflow.providers.amazon.aws.hooks.emr import EmrHook
+from airflow.providers.amazon.aws.hooks.emr import EmrContainerHook, EmrHook
from airflow.providers.amazon.aws.links.emr import EmrClusterLink
if TYPE_CHECKING:
from airflow.utils.context import Context
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
-from airflow.providers.amazon.aws.hooks.emr import EmrContainerHook
-
-
class EmrAddStepsOperator(BaseOperator):
"""
An operator that adds steps to an existing EMR job_flow.
diff --git a/airflow/providers/amazon/aws/operators/glue_crawler.py
b/airflow/providers/amazon/aws/operators/glue_crawler.py
index a584301f92..f771e1b80c 100644
--- a/airflow/providers/amazon/aws/operators/glue_crawler.py
+++ b/airflow/providers/amazon/aws/operators/glue_crawler.py
@@ -15,19 +15,13 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import sys
import warnings
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from airflow.utils.context import Context
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.models import BaseOperator
from airflow.providers.amazon.aws.hooks.glue_crawler import GlueCrawlerHook
diff --git a/airflow/providers/amazon/aws/operators/redshift_data.py
b/airflow/providers/amazon/aws/operators/redshift_data.py
index 07854544a5..f23ca928eb 100644
--- a/airflow/providers/amazon/aws/operators/redshift_data.py
+++ b/airflow/providers/amazon/aws/operators/redshift_data.py
@@ -15,16 +15,10 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-
-import sys
from time import sleep
from typing import TYPE_CHECKING, Any, Dict, Optional
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.models import BaseOperator
from airflow.providers.amazon.aws.hooks.redshift_data import RedshiftDataHook
diff --git a/airflow/providers/amazon/aws/operators/sagemaker.py
b/airflow/providers/amazon/aws/operators/sagemaker.py
index 084e3e857e..6a6ef69df4 100644
--- a/airflow/providers/amazon/aws/operators/sagemaker.py
+++ b/airflow/providers/amazon/aws/operators/sagemaker.py
@@ -16,21 +16,16 @@
# under the License.
import json
-import sys
from typing import TYPE_CHECKING, Any, List, Optional, Sequence
from botocore.exceptions import ClientError
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.models import BaseOperator
from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
from airflow.providers.amazon.aws.hooks.sagemaker import SageMakerHook
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
if TYPE_CHECKING:
from airflow.utils.context import Context
diff --git a/airflow/providers/amazon/aws/secrets/secrets_manager.py
b/airflow/providers/amazon/aws/secrets/secrets_manager.py
index c740077a56..0ee73bc330 100644
--- a/airflow/providers/amazon/aws/secrets/secrets_manager.py
+++ b/airflow/providers/amazon/aws/secrets/secrets_manager.py
@@ -20,20 +20,14 @@
import ast
import json
import re
-import sys
import warnings
from typing import Optional
from urllib.parse import urlencode
import boto3
+from airflow.compat.functools import cached_property
from airflow.providers.amazon.aws.utils import get_airflow_version
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from airflow.secrets import BaseSecretsBackend
from airflow.utils.log.logging_mixin import LoggingMixin
diff --git a/airflow/providers/amazon/aws/secrets/systems_manager.py
b/airflow/providers/amazon/aws/secrets/systems_manager.py
index 140fec11ef..27f216c5e2 100644
--- a/airflow/providers/amazon/aws/secrets/systems_manager.py
+++ b/airflow/providers/amazon/aws/secrets/systems_manager.py
@@ -17,19 +17,13 @@
# under the License.
"""Objects relating to sourcing connections from AWS SSM Parameter Store"""
import re
-import sys
import warnings
from typing import Optional
import boto3
+from airflow.compat.functools import cached_property
from airflow.providers.amazon.aws.utils import get_airflow_version
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from airflow.secrets import BaseSecretsBackend
from airflow.utils.log.logging_mixin import LoggingMixin
diff --git a/airflow/providers/amazon/aws/sensors/athena.py
b/airflow/providers/amazon/aws/sensors/athena.py
index 1186f8cdef..4269ca01dd 100644
--- a/airflow/providers/amazon/aws/sensors/athena.py
+++ b/airflow/providers/amazon/aws/sensors/athena.py
@@ -15,17 +15,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import sys
from typing import TYPE_CHECKING, Any, Optional, Sequence
if TYPE_CHECKING:
from airflow.utils.context import Context
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.providers.amazon.aws.hooks.athena import AthenaHook
from airflow.sensors.base import BaseSensorOperator
diff --git a/airflow/providers/amazon/aws/sensors/cloud_formation.py
b/airflow/providers/amazon/aws/sensors/cloud_formation.py
index 17d42099a7..290da5ad73 100644
--- a/airflow/providers/amazon/aws/sensors/cloud_formation.py
+++ b/airflow/providers/amazon/aws/sensors/cloud_formation.py
@@ -16,17 +16,12 @@
# specific language governing permissions and limitations
# under the License.
"""This module contains sensors for AWS CloudFormation."""
-import sys
from typing import TYPE_CHECKING, Optional, Sequence
if TYPE_CHECKING:
from airflow.utils.context import Context
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.providers.amazon.aws.hooks.cloud_formation import
CloudFormationHook
from airflow.sensors.base import BaseSensorOperator
diff --git a/airflow/providers/amazon/aws/sensors/emr.py
b/airflow/providers/amazon/aws/sensors/emr.py
index a4c2b3a711..62c74ea560 100644
--- a/airflow/providers/amazon/aws/sensors/emr.py
+++ b/airflow/providers/amazon/aws/sensors/emr.py
@@ -15,18 +15,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import sys
from typing import TYPE_CHECKING, Any, Dict, Iterable, Optional, Sequence
if TYPE_CHECKING:
from airflow.utils.context import Context
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.providers.amazon.aws.hooks.emr import EmrContainerHook, EmrHook
from airflow.sensors.base import BaseSensorOperator
diff --git a/airflow/providers/amazon/aws/sensors/quicksight.py
b/airflow/providers/amazon/aws/sensors/quicksight.py
index da94980e80..4e28d5761a 100644
--- a/airflow/providers/amazon/aws/sensors/quicksight.py
+++ b/airflow/providers/amazon/aws/sensors/quicksight.py
@@ -16,9 +16,9 @@
# specific language governing permissions and limitations
# under the License.
-import sys
from typing import TYPE_CHECKING, Optional
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.providers.amazon.aws.hooks.quicksight import QuickSightHook
from airflow.providers.amazon.aws.hooks.sts import StsHook
@@ -27,11 +27,6 @@ from airflow.sensors.base import BaseSensorOperator
if TYPE_CHECKING:
from airflow.utils.context import Context
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
class QuickSightSensor(BaseSensorOperator):
"""
diff --git a/airflow/providers/amazon/aws/sensors/s3.py
b/airflow/providers/amazon/aws/sensors/s3.py
index 21b06432f2..cb27ed574a 100644
--- a/airflow/providers/amazon/aws/sensors/s3.py
+++ b/airflow/providers/amazon/aws/sensors/s3.py
@@ -19,7 +19,6 @@
import fnmatch
import os
import re
-import sys
import warnings
from datetime import datetime
from typing import TYPE_CHECKING, Callable, List, Optional, Sequence, Set,
Union
@@ -27,12 +26,7 @@ from typing import TYPE_CHECKING, Callable, List, Optional,
Sequence, Set, Union
if TYPE_CHECKING:
from airflow.utils.context import Context
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.providers.amazon.aws.hooks.s3 import S3Hook
from airflow.sensors.base import BaseSensorOperator, poke_mode_only
diff --git a/airflow/providers/asana/hooks/asana.py
b/airflow/providers/asana/hooks/asana.py
index 45816437f8..9684ab8276 100644
--- a/airflow/providers/asana/hooks/asana.py
+++ b/airflow/providers/asana/hooks/asana.py
@@ -17,17 +17,12 @@
# under the License.
"""Connect to Asana."""
-import sys
from typing import Any, Dict, Optional
from asana import Client # type: ignore[attr-defined]
from asana.error import NotFoundError # type: ignore[attr-defined]
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.hooks.base import BaseHook
diff --git a/airflow/providers/cncf/kubernetes/hooks/kubernetes.py
b/airflow/providers/cncf/kubernetes/hooks/kubernetes.py
index ad7762ed4f..c4658ec8f3 100644
--- a/airflow/providers/cncf/kubernetes/hooks/kubernetes.py
+++ b/airflow/providers/cncf/kubernetes/hooks/kubernetes.py
@@ -14,22 +14,16 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import sys
import tempfile
import warnings
from typing import Any, Dict, Generator, List, Optional, Tuple, Union
+from kubernetes import client, config, watch
from kubernetes.config import ConfigException
+from airflow.compat.functools import cached_property
from airflow.kubernetes.kube_client import _disable_verify_ssl,
_enable_tcp_keepalive
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
-from kubernetes import client, config, watch
-
try:
import airflow.utils.yaml as yaml
except ImportError:
diff --git a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py
b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py
index 411b621ce8..07435436ce 100644
--- a/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py
+++ b/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py
@@ -18,13 +18,13 @@
import json
import logging
import re
-import sys
import warnings
from contextlib import AbstractContextManager
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence
from kubernetes.client import CoreV1Api, models as k8s
+from airflow.compat.functools import cached_property
from airflow.configuration import conf
from airflow.exceptions import AirflowException
from airflow.kubernetes import pod_generator
@@ -56,11 +56,6 @@ from airflow.utils import yaml
from airflow.utils.helpers import prune_dict, validate_key
from airflow.version import version as airflow_version
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
if TYPE_CHECKING:
import jinja2
diff --git a/airflow/providers/databricks/hooks/databricks_base.py
b/airflow/providers/databricks/hooks/databricks_base.py
index 5b18dad930..28b7feaf84 100644
--- a/airflow/providers/databricks/hooks/databricks_base.py
+++ b/airflow/providers/databricks/hooks/databricks_base.py
@@ -23,7 +23,6 @@ operators talk to the ``api/2.0/jobs/runs/submit``
`endpoint <https://docs.databricks.com/api/latest/jobs.html#runs-submit>`_.
"""
import copy
-import sys
import time
from typing import Any, Dict, Optional, Tuple
from urllib.parse import urlparse
@@ -43,15 +42,11 @@ from tenacity import (
)
from airflow import __version__
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.hooks.base import BaseHook
from airflow.models import Connection
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
USER_AGENT_HEADER = {'user-agent': f'airflow-{__version__}'}
#
https://docs.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/aad/service-prin-aad-token#--get-an-azure-active-directory-access-token
diff --git a/airflow/providers/dbt/cloud/hooks/dbt.py
b/airflow/providers/dbt/cloud/hooks/dbt.py
index 31214d7342..07a327a045 100644
--- a/airflow/providers/dbt/cloud/hooks/dbt.py
+++ b/airflow/providers/dbt/cloud/hooks/dbt.py
@@ -16,7 +16,6 @@
# under the License.
import json
-import sys
import time
from enum import Enum
from functools import wraps
@@ -27,16 +26,12 @@ from requests import PreparedRequest, Session
from requests.auth import AuthBase
from requests.models import Response
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.models import Connection
from airflow.providers.http.hooks.http import HttpHook
from airflow.typing_compat import TypedDict
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
def fallback_to_default_account(func: Callable) -> Callable:
"""
diff --git a/airflow/providers/facebook/ads/hooks/ads.py
b/airflow/providers/facebook/ads/hooks/ads.py
index 96f2db9737..225a30cfa0 100644
--- a/airflow/providers/facebook/ads/hooks/ads.py
+++ b/airflow/providers/facebook/ads/hooks/ads.py
@@ -16,21 +16,16 @@
# specific language governing permissions and limitations
# under the License.
"""This module contains Facebook Ads Reporting hooks"""
-import sys
import time
from enum import Enum
from typing import Any, Dict, List, Optional, Union
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.adreportrun import AdReportRun
from facebook_business.adobjects.adsinsights import AdsInsights
from facebook_business.api import FacebookAdsApi
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.hooks.base import BaseHook
diff --git a/airflow/providers/google/ads/hooks/ads.py
b/airflow/providers/google/ads/hooks/ads.py
index c94997fa2f..993a4970df 100644
--- a/airflow/providers/google/ads/hooks/ads.py
+++ b/airflow/providers/google/ads/hooks/ads.py
@@ -16,15 +16,9 @@
# specific language governing permissions and limitations
# under the License.
"""This module contains Google Ad hook."""
-import sys
from tempfile import NamedTemporaryFile
from typing import IO, Any, Dict, List, Optional
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v10.services.services.customer_service import
CustomerServiceClient
@@ -34,6 +28,7 @@ from google.api_core.page_iterator import GRPCIterator
from google.auth.exceptions import GoogleAuthError
from airflow import AirflowException
+from airflow.compat.functools import cached_property
from airflow.hooks.base import BaseHook
diff --git
a/airflow/providers/google/cloud/_internal_client/secret_manager_client.py
b/airflow/providers/google/cloud/_internal_client/secret_manager_client.py
index 203cc7ac0b..c2c49ca47a 100644
--- a/airflow/providers/google/cloud/_internal_client/secret_manager_client.py
+++ b/airflow/providers/google/cloud/_internal_client/secret_manager_client.py
@@ -16,21 +16,14 @@
# under the License.
import re
-import sys
from typing import Optional
import google
-
-from airflow.providers.google.common.consts import CLIENT_INFO
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from google.api_core.exceptions import InvalidArgument, NotFound,
PermissionDenied
from google.cloud.secretmanager_v1 import SecretManagerServiceClient
+from airflow.compat.functools import cached_property
+from airflow.providers.google.common.consts import CLIENT_INFO
from airflow.utils.log.logging_mixin import LoggingMixin
SECRET_ID_PATTERN = r"^[a-zA-Z0-9-_]*$"
diff --git a/airflow/providers/google/cloud/hooks/automl.py
b/airflow/providers/google/cloud/hooks/automl.py
index dbe375ac5a..aace911993 100644
--- a/airflow/providers/google/cloud/hooks/automl.py
+++ b/airflow/providers/google/cloud/hooks/automl.py
@@ -23,22 +23,8 @@ This module contains a Google AutoML hook.
PredictResponse
"""
-import sys
from typing import Dict, Optional, Sequence, Tuple, Union
-from google.cloud.automl_v1beta1.services.auto_ml.pagers import (
- ListColumnSpecsPager,
- ListDatasetsPager,
- ListTableSpecsPager,
-)
-
-from airflow.providers.google.common.consts import CLIENT_INFO
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
from google.api_core.operation import Operation
from google.api_core.retry import Retry
@@ -54,8 +40,15 @@ from google.cloud.automl_v1beta1 import (
PredictionServiceClient,
PredictResponse,
)
+from google.cloud.automl_v1beta1.services.auto_ml.pagers import (
+ ListColumnSpecsPager,
+ ListDatasetsPager,
+ ListTableSpecsPager,
+)
from google.protobuf.field_mask_pb2 import FieldMask
+from airflow.compat.functools import cached_property
+from airflow.providers.google.common.consts import CLIENT_INFO
from airflow.providers.google.common.hooks.base_google import
PROVIDE_PROJECT_ID, GoogleBaseHook
diff --git a/airflow/providers/google/cloud/hooks/compute_ssh.py
b/airflow/providers/google/cloud/hooks/compute_ssh.py
index 3b65ce4a72..76192a509a 100644
--- a/airflow/providers/google/cloud/hooks/compute_ssh.py
+++ b/airflow/providers/google/cloud/hooks/compute_ssh.py
@@ -15,19 +15,14 @@
# specific language governing permissions and limitations
# under the License.
import shlex
-import sys
import time
from io import StringIO
from typing import Any, Dict, Optional
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from google.api_core.retry import exponential_sleep_generator
from airflow import AirflowException
+from airflow.compat.functools import cached_property
from airflow.providers.google.cloud.hooks.compute import ComputeEngineHook
from airflow.providers.google.cloud.hooks.os_login import OSLoginHook
from airflow.providers.ssh.hooks.ssh import SSHHook
diff --git a/airflow/providers/google/cloud/hooks/pubsub.py
b/airflow/providers/google/cloud/hooks/pubsub.py
index 535f912f8b..82fe34c331 100644
--- a/airflow/providers/google/cloud/hooks/pubsub.py
+++ b/airflow/providers/google/cloud/hooks/pubsub.py
@@ -23,19 +23,11 @@ This module contains a Google Pub/Sub Hook.
MessageStoragePolicy
ReceivedMessage
"""
-import sys
import warnings
from base64 import b64decode
from typing import Dict, List, Optional, Sequence, Tuple, Union
from uuid import uuid4
-from airflow.providers.google.common.consts import CLIENT_INFO
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from google.api_core.exceptions import AlreadyExists, GoogleAPICallError
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
from google.api_core.retry import Retry
@@ -52,6 +44,8 @@ from google.cloud.pubsub_v1.types import (
)
from googleapiclient.errors import HttpError
+from airflow.compat.functools import cached_property
+from airflow.providers.google.common.consts import CLIENT_INFO
from airflow.providers.google.common.hooks.base_google import
PROVIDE_PROJECT_ID, GoogleBaseHook
from airflow.version import version
diff --git a/airflow/providers/google/cloud/hooks/vision.py
b/airflow/providers/google/cloud/hooks/vision.py
index 1d4d232a1e..cbe890962e 100644
--- a/airflow/providers/google/cloud/hooks/vision.py
+++ b/airflow/providers/google/cloud/hooks/vision.py
@@ -16,17 +16,9 @@
# specific language governing permissions and limitations
# under the License.
"""This module contains a Google Cloud Vision Hook."""
-import sys
from copy import deepcopy
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
-from airflow.providers.google.common.consts import CLIENT_INFO
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
from google.api_core.retry import Retry
from google.cloud.vision_v1 import ImageAnnotatorClient, ProductSearchClient
@@ -40,7 +32,9 @@ from google.cloud.vision_v1.types import (
)
from google.protobuf.json_format import MessageToDict
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
+from airflow.providers.google.common.consts import CLIENT_INFO
from airflow.providers.google.common.hooks.base_google import
PROVIDE_PROJECT_ID, GoogleBaseHook
ERR_DIFF_NAMES = """The {label} name provided in the object ({explicit_name})
is different
diff --git a/airflow/providers/google/cloud/log/gcs_task_handler.py
b/airflow/providers/google/cloud/log/gcs_task_handler.py
index 81f1426d75..0b4c0e09f2 100644
--- a/airflow/providers/google/cloud/log/gcs_task_handler.py
+++ b/airflow/providers/google/cloud/log/gcs_task_handler.py
@@ -16,20 +16,14 @@
# specific language governing permissions and limitations
# under the License.
import os
-import sys
from typing import Collection, Optional
-from airflow.providers.google.common.consts import CLIENT_INFO
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
# not sure why but mypy complains on missing `storage` but it is clearly there
and is importable
from google.cloud import storage # type: ignore[attr-defined]
+from airflow.compat.functools import cached_property
from airflow.providers.google.cloud.utils.credentials_provider import
get_credentials_and_project_id
+from airflow.providers.google.common.consts import CLIENT_INFO
from airflow.utils.log.file_task_handler import FileTaskHandler
from airflow.utils.log.logging_mixin import LoggingMixin
diff --git a/airflow/providers/google/cloud/log/stackdriver_task_handler.py
b/airflow/providers/google/cloud/log/stackdriver_task_handler.py
index 94ce5e57b0..d92d8e8da5 100644
--- a/airflow/providers/google/cloud/log/stackdriver_task_handler.py
+++ b/airflow/providers/google/cloud/log/stackdriver_task_handler.py
@@ -16,17 +16,9 @@
# under the License.
"""Handler that integrates with Stackdriver"""
import logging
-import sys
from typing import Collection, Dict, List, Optional, Tuple, Type, Union
from urllib.parse import urlencode
-from airflow.providers.google.common.consts import CLIENT_INFO
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from google.auth.credentials import Credentials
from google.cloud import logging as gcp_logging
from google.cloud.logging import Resource
@@ -34,8 +26,10 @@ from google.cloud.logging.handlers.transports import
BackgroundThreadTransport,
from google.cloud.logging_v2.services.logging_service_v2 import
LoggingServiceV2Client
from google.cloud.logging_v2.types import ListLogEntriesRequest,
ListLogEntriesResponse
+from airflow.compat.functools import cached_property
from airflow.models import TaskInstance
from airflow.providers.google.cloud.utils.credentials_provider import
get_credentials_and_project_id
+from airflow.providers.google.common.consts import CLIENT_INFO
DEFAULT_LOGGER_NAME = "airflow"
_GLOBAL_RESOURCE = Resource(type="global", labels={})
diff --git a/airflow/providers/hashicorp/_internal_client/vault_client.py
b/airflow/providers/hashicorp/_internal_client/vault_client.py
index ee36c21f7e..4b69907efe 100644
--- a/airflow/providers/hashicorp/_internal_client/vault_client.py
+++ b/airflow/providers/hashicorp/_internal_client/vault_client.py
@@ -14,19 +14,13 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-import sys
from typing import List, Optional
import hvac
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
from hvac.exceptions import InvalidPath, VaultError
from requests import Response
+from airflow.compat.functools import cached_property
from airflow.utils.log.logging_mixin import LoggingMixin
DEFAULT_KUBERNETES_JWT_PATH =
'/var/run/secrets/kubernetes.io/serviceaccount/token'
diff --git a/airflow/providers/microsoft/azure/log/wasb_task_handler.py
b/airflow/providers/microsoft/azure/log/wasb_task_handler.py
index f5e89c2c21..47a6e824bc 100644
--- a/airflow/providers/microsoft/azure/log/wasb_task_handler.py
+++ b/airflow/providers/microsoft/azure/log/wasb_task_handler.py
@@ -17,16 +17,11 @@
# under the License.
import os
import shutil
-import sys
from typing import Dict, Optional, Tuple
from azure.common import AzureHttpError
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.configuration import conf
from airflow.utils.log.file_task_handler import FileTaskHandler
from airflow.utils.log.logging_mixin import LoggingMixin
diff --git a/airflow/providers/microsoft/azure/secrets/key_vault.py
b/airflow/providers/microsoft/azure/secrets/key_vault.py
index 0dde708a8d..19eacf010c 100644
--- a/airflow/providers/microsoft/azure/secrets/key_vault.py
+++ b/airflow/providers/microsoft/azure/secrets/key_vault.py
@@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
import re
-import sys
import warnings
from typing import Optional
@@ -23,15 +22,10 @@ from azure.core.exceptions import ResourceNotFoundError
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
-from airflow.version import version as airflow_version
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.secrets import BaseSecretsBackend
from airflow.utils.log.logging_mixin import LoggingMixin
+from airflow.version import version as airflow_version
def _parse_version(val):
diff --git a/airflow/providers/microsoft/azure/transfers/sftp_to_wasb.py
b/airflow/providers/microsoft/azure/transfers/sftp_to_wasb.py
index 1b50865cbd..8af4ba971e 100644
--- a/airflow/providers/microsoft/azure/transfers/sftp_to_wasb.py
+++ b/airflow/providers/microsoft/azure/transfers/sftp_to_wasb.py
@@ -17,7 +17,6 @@
# under the License.
"""This module contains SFTP to Azure Blob Storage operator."""
import os
-import sys
from collections import namedtuple
from tempfile import NamedTemporaryFile
from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple
@@ -25,12 +24,7 @@ from typing import TYPE_CHECKING, Dict, List, Optional,
Sequence, Tuple
if TYPE_CHECKING:
from airflow.utils.context import Context
-
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.models import BaseOperator
from airflow.providers.microsoft.azure.hooks.wasb import WasbHook
diff --git a/airflow/providers/salesforce/hooks/salesforce.py
b/airflow/providers/salesforce/hooks/salesforce.py
index cdb2c918e9..97c2697b45 100644
--- a/airflow/providers/salesforce/hooks/salesforce.py
+++ b/airflow/providers/salesforce/hooks/salesforce.py
@@ -24,19 +24,14 @@ retrieve data from it, and write that data to a file for
other uses.
https://github.com/simple-salesforce/simple-salesforce
"""
import logging
-import sys
import time
from typing import Any, Dict, Iterable, List, Optional
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
import pandas as pd
from requests import Session
from simple_salesforce import Salesforce, api
+from airflow.compat.functools import cached_property
from airflow.hooks.base import BaseHook
log = logging.getLogger(__name__)
diff --git a/airflow/providers/ssh/hooks/ssh.py
b/airflow/providers/ssh/hooks/ssh.py
index 51240820ec..412842daa8 100644
--- a/airflow/providers/ssh/hooks/ssh.py
+++ b/airflow/providers/ssh/hooks/ssh.py
@@ -17,7 +17,6 @@
# under the License.
"""Hook for SSH connections."""
import os
-import sys
import warnings
from base64 import decodebytes
from io import StringIO
@@ -29,11 +28,7 @@ from paramiko.config import SSH_PORT
from sshtunnel import SSHTunnelForwarder
from tenacity import Retrying, stop_after_attempt, wait_fixed, wait_random
-if sys.version_info >= (3, 8):
- from functools import cached_property
-else:
- from cached_property import cached_property
-
+from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.hooks.base import BaseHook