Skip to content

Commit

Permalink
Use built-in cached_property on Python 3.8 where possible (#14606)
Browse files Browse the repository at this point in the history
Functionality is the same, this just removes one dep for Py 3.8+
  • Loading branch information
ashb committed Mar 6, 2021
1 parent e468b31 commit e7bb17a
Show file tree
Hide file tree
Showing 31 changed files with 128 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ENV DEBIAN_FRONTEND=noninteractive LANGUAGE=C.UTF-8 LANG=C.UTF-8 LC_ALL=C.UTF-8
LC_CTYPE=C.UTF-8 LC_MESSAGES=C.UTF-8

# By increasing this number we can do force build of all dependencies
ARG DEPENDENCIES_EPOCH_NUMBER="5"
ARG DEPENDENCIES_EPOCH_NUMBER="6"
# Increase the value below to force reinstalling of all dependencies
ENV DEPENDENCIES_EPOCH_NUMBER=${DEPENDENCIES_EPOCH_NUMBER}

Expand Down
6 changes: 5 additions & 1 deletion airflow/models/baseoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@

import attr
import jinja2
from cached_property import cached_property

try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from dateutil.relativedelta import relativedelta
from sqlalchemy.orm import Session

Expand Down
5 changes: 4 additions & 1 deletion airflow/operators/bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import os
from typing import Dict, Optional

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.exceptions import AirflowException, AirflowSkipException
from airflow.hooks.subprocess import EXIT_CODE_SKIP, SubprocessHook
Expand Down
5 changes: 4 additions & 1 deletion airflow/operators/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
from distutils.util import strtobool
from typing import Any, Dict, Iterable, List, Mapping, Optional, SupportsAbs, Union

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.exceptions import AirflowException
from airflow.hooks.base import BaseHook
Expand Down
6 changes: 5 additions & 1 deletion airflow/providers/amazon/aws/hooks/base_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
import botocore.session
from botocore.config import Config
from botocore.credentials import ReadOnlyCredentials
from cached_property import cached_property

try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from dateutil.tz import tzlocal

from airflow.exceptions import AirflowException
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/amazon/aws/hooks/glue_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

from time import sleep

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.exceptions import AirflowException
from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
Expand Down
6 changes: 5 additions & 1 deletion airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
# under the License.

import watchtower
from cached_property import cached_property

try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.configuration import conf
from airflow.utils.log.file_task_handler import FileTaskHandler
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/amazon/aws/log/s3_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
# under the License.
import os

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.configuration import conf
from airflow.utils.log.file_task_handler import FileTaskHandler
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/amazon/aws/operators/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
from typing import Any, Dict, Optional
from uuid import uuid4

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.models import BaseOperator
from airflow.providers.amazon.aws.hooks.athena import AWSAthenaHook
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/amazon/aws/operators/glue_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
# specific language governing permissions and limitations
# under the License.

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.models import BaseOperator
from airflow.providers.amazon.aws.hooks.glue_crawler import AwsGlueCrawlerHook
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/amazon/aws/operators/sagemaker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import json
from typing import Iterable

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.models import BaseOperator
from airflow.providers.amazon.aws.hooks.sagemaker import SageMakerHook
Expand Down
6 changes: 5 additions & 1 deletion airflow/providers/amazon/aws/secrets/secrets_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
from typing import Optional

import boto3
from cached_property import cached_property

try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.secrets import BaseSecretsBackend
from airflow.utils.log.logging_mixin import LoggingMixin
Expand Down
6 changes: 5 additions & 1 deletion airflow/providers/amazon/aws/secrets/systems_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
from typing import Optional

import boto3
from cached_property import cached_property

try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.secrets import BaseSecretsBackend
from airflow.utils.log.logging_mixin import LoggingMixin
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/amazon/aws/sensors/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
# under the License.
from typing import Any, Optional

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.exceptions import AirflowException
from airflow.providers.amazon.aws.hooks.athena import AWSAthenaHook
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/amazon/aws/sensors/s3_keys_unchanged.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
from datetime import datetime
from typing import Optional, Set, Union

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.exceptions import AirflowException
from airflow.providers.amazon.aws.hooks.s3 import S3Hook
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/cncf/kubernetes/hooks/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
import tempfile
from typing import Any, Dict, Generator, Optional, Tuple, Union

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from kubernetes import client, config, watch

try:
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/facebook/ads/hooks/ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
from enum import Enum
from typing import Any, Dict, List

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
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
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/google/ads/hooks/ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
from tempfile import NamedTemporaryFile
from typing import IO, Any, Dict, Generator, List

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from google.ads.google_ads.client import GoogleAdsClient
from google.ads.google_ads.errors import GoogleAdsException
from google.ads.google_ads.v2.types import GoogleAdsRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
from typing import Optional

import google
from cached_property import cached_property

try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from google.api_core.exceptions import NotFound, PermissionDenied
from google.api_core.gapic_v1.client_info import ClientInfo
from google.cloud.secretmanager_v1 import SecretManagerServiceClient
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/google/cloud/hooks/automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"""This module contains a Google AutoML hook."""
from typing import Dict, List, Optional, Sequence, Tuple, Union

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from google.api_core.operation import Operation
from google.api_core.retry import Retry
from google.cloud.automl_v1beta1 import (
Expand Down
6 changes: 5 additions & 1 deletion airflow/providers/google/cloud/hooks/compute_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
from typing import Any, Dict, Optional

import paramiko
from cached_property import cached_property

try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from google.api_core.retry import exponential_sleep_generator

from airflow import AirflowException
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/google/cloud/hooks/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
from typing import Dict, List, Optional, Sequence, Tuple, Union
from uuid import uuid4

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from google.api_core.exceptions import AlreadyExists, GoogleAPICallError
from google.api_core.retry import Retry
from google.cloud.exceptions import NotFound
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/google/cloud/hooks/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
from copy import deepcopy
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from google.api_core.retry import Retry
from google.cloud.vision_v1 import ImageAnnotatorClient, ProductSearchClient
from google.cloud.vision_v1.types import (
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/google/cloud/log/gcs_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import os
from typing import Collection, Optional

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from google.api_core.client_info import ClientInfo
from google.cloud import storage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
from typing import Collection, Dict, List, Optional, Tuple, Type
from urllib.parse import urlencode

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from google.api_core.gapic_v1.client_info import ClientInfo
from google.auth.credentials import Credentials
from google.cloud import logging as gcp_logging
Expand Down
5 changes: 4 additions & 1 deletion airflow/providers/google/cloud/secrets/secret_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
"""Objects relating to sourcing connections from Google Cloud Secrets Manager"""
from typing import Optional

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.exceptions import AirflowException
from airflow.providers.google.cloud._internal_client.secret_manager_client import _SecretManagerClient # noqa
Expand Down
6 changes: 5 additions & 1 deletion airflow/providers/hashicorp/_internal_client/vault_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
from typing import List, Optional

import hvac
from cached_property import cached_property

try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from hvac.exceptions import InvalidPath, VaultError
from requests import Response

Expand Down
6 changes: 5 additions & 1 deletion airflow/providers/microsoft/azure/log/wasb_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
from typing import Dict, Optional, Tuple

from azure.common import AzureHttpError
from cached_property import cached_property

try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.configuration import conf
from airflow.utils.log.file_task_handler import FileTaskHandler
Expand Down
6 changes: 5 additions & 1 deletion airflow/providers/microsoft/azure/secrets/azure_key_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
from azure.core.exceptions import ResourceNotFoundError
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
from cached_property import cached_property

try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.secrets import BaseSecretsBackend
from airflow.utils.log.logging_mixin import LoggingMixin
Expand Down
5 changes: 4 additions & 1 deletion airflow/utils/log/log_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import logging
from typing import Dict, Iterator, List, Optional, Tuple

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from airflow.configuration import conf
from airflow.models import TaskInstance
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ install_requires =
alembic>=1.2, <2.0
argcomplete~=1.10
attrs>=20.0, <21.0
cached_property~=1.5
cached_property~=1.5;python_version<="3.7"
# cattrs >= 1.1.0 dropped support for Python 3.6
cattrs>=1.0, <1.1.0;python_version<="3.6"
cattrs~=1.1;python_version>"3.6"
Expand Down

0 comments on commit e7bb17a

Please sign in to comment.