Skip to content

Commit

Permalink
Update providers to use functools compat for cached_property (#24582
Browse files Browse the repository at this point in the history
)
  • Loading branch information
josh-fell committed Jun 22, 2022
1 parent e477f4b commit 9c59831
Show file tree
Hide file tree
Showing 39 changed files with 53 additions and 269 deletions.
7 changes: 1 addition & 6 deletions airflow/providers/alibaba/cloud/log/oss_task_handler.py
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/alibaba/cloud/sensors/oss_key.py
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/hooks/glue_crawler.py
Expand Up @@ -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

Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/hooks/quicksight.py
Expand Up @@ -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):
"""
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/hooks/redshift_sql.py
Expand Up @@ -15,21 +15,16 @@
# specific language governing permissions and limitations
# under the License.

import sys
from typing import Dict, List, Optional, Union

import redshift_connector
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):
"""
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/log/s3_task_handler.py
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/operators/athena.py
Expand Up @@ -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

Expand Down
12 changes: 2 additions & 10 deletions airflow/providers/amazon/aws/operators/emr.py
Expand Up @@ -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.
Expand Down
8 changes: 1 addition & 7 deletions airflow/providers/amazon/aws/operators/glue_crawler.py
Expand Up @@ -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

Expand Down
8 changes: 1 addition & 7 deletions airflow/providers/amazon/aws/operators/redshift_data.py
Expand Up @@ -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

Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/operators/sagemaker.py
Expand Up @@ -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

Expand Down
8 changes: 1 addition & 7 deletions airflow/providers/amazon/aws/secrets/secrets_manager.py
Expand Up @@ -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

Expand Down
8 changes: 1 addition & 7 deletions airflow/providers/amazon/aws/secrets/systems_manager.py
Expand Up @@ -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

Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/sensors/athena.py
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/sensors/cloud_formation.py
Expand Up @@ -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

Expand Down
8 changes: 1 addition & 7 deletions airflow/providers/amazon/aws/sensors/emr.py
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/sensors/quicksight.py
Expand Up @@ -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
Expand All @@ -27,11 +27,6 @@
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):
"""
Expand Down
8 changes: 1 addition & 7 deletions airflow/providers/amazon/aws/sensors/s3.py
Expand Up @@ -19,20 +19,14 @@
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

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

0 comments on commit 9c59831

Please sign in to comment.