Content-Length: 1376535 | pFad | https://github.com/apache/airflow/commit/44d4ae809c1e3784ff95b6a5e95113c3412e56b3

55 Upgrade to latest pre-commit checks (#9686) · apache/airflow@44d4ae8 · GitHub
Skip to content

Commit 44d4ae8

Browse files
authored
Upgrade to latest pre-commit checks (#9686)
1 parent 2ed8883 commit 44d4ae8

File tree

59 files changed

+105
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+105
-141
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ repos:
168168
types: [yaml]
169169
exclude: ^.*init_git_sync\.template\.yaml$|^.*airflow\.template\.yaml$|^chart/templates/.*\.yaml$
170170
- repo: https://github.com/timothycrosley/isort
171-
rev: 4.3.21-2
171+
rev: 5.0.3
172172
hooks:
173173
- id: isort
174174
name: Run isort to sort imports

airflow/example_dags/example_python_operator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# under the License.
1818

1919
"""Example DAG demonstrating the usage of the PythonOperator."""
20-
2120
import time
2221
from pprint import pprint
2322

@@ -80,8 +79,9 @@ def callable_virtualenv():
8079
Importing at the module level ensures that it will not attempt to import the
8180
library before it is installed.
8281
"""
83-
from colorama import Fore, Back, Style
8482
from time import sleep
83+
84+
from colorama import Back, Fore, Style
8585
print(Fore.RED + 'some red text')
8686
print(Back.GREEN + 'and with a green background')
8787
print(Style.DIM + 'and in dim text')

airflow/hooks/dbapi_hook.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
1918
from contextlib import closing
2019
from datetime import datetime
2120
from typing import Any, Optional
@@ -117,7 +116,7 @@ def get_pandas_df(self, sql, parameters=None):
117116
:param parameters: The parameters to render the SQL query with.
118117
:type parameters: dict or iterable
119118
"""
120-
import pandas.io.sql as psql
119+
from pandas.io import sql as psql
121120

122121
with closing(self.get_conn()) as conn:
123122
return psql.read_sql(sql, con=conn, params=parameters)

airflow/kubernetes/k8s_model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
"""
1818
Classes for interacting with Kubernetes API.
1919
"""
20-
2120
from abc import ABC, abstractmethod
2221
from functools import reduce
2322
from typing import List, Optional
2423

25-
import kubernetes.client.models as k8s
24+
from kubernetes.client import models as k8s
2625

2726

2827
class K8SModel(ABC):

airflow/kubernetes/kube_client.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
"""Client for kubernetes communication"""
18-
1918
from typing import Optional
2019

2120
from airflow.configuration import conf
2221

2322
try:
24-
from kubernetes import config, client
25-
from kubernetes.client.rest import ApiException # pylint: disable=unused-import
26-
from kubernetes.client.api_client import ApiClient
23+
from kubernetes import client, config
2724
from kubernetes.client import Configuration
25+
from kubernetes.client.api_client import ApiClient
26+
from kubernetes.client.rest import ApiException # pylint: disable=unused-import
27+
2828
from airflow.kubernetes.refresh_config import ( # pylint: disable=ungrouped-imports
29-
load_kube_config,
30-
RefreshConfiguration,
29+
RefreshConfiguration, load_kube_config,
3130
)
3231
has_kubernetes = True
3332

airflow/kubernetes/pod.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
"""
1818
Classes for interacting with Kubernetes API
1919
"""
20-
2120
import copy
2221

23-
import kubernetes.client.models as k8s
22+
from kubernetes.client import models as k8s
2423

2524
from airflow.kubernetes.k8s_model import K8SModel
2625

airflow/kubernetes/pod_generator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
The advantage being that the full Kubernetes API
2121
is supported and no serialization need be written.
2222
"""
23-
2423
import copy
2524
import hashlib
2625
import inspect
@@ -30,8 +29,8 @@
3029
from functools import reduce
3130
from typing import Dict, List, Optional, Union
3231

33-
import kubernetes.client.models as k8s
3432
import yaml
33+
from kubernetes.client import models as k8s
3534
from kubernetes.client.api_client import ApiClient
3635

3736
from airflow.exceptions import AirflowConfigException

airflow/kubernetes/pod_runtime_info_env.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
"""
1818
Classes for interacting with Kubernetes API
1919
"""
20-
2120
import copy
2221

23-
import kubernetes.client.models as k8s
22+
from kubernetes.client import models as k8s
2423

2524
from airflow.kubernetes.k8s_model import K8SModel
2625

airflow/kubernetes/secret.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
"""
1818
Classes for interacting with Kubernetes API
1919
"""
20-
2120
import copy
2221
import uuid
2322
from typing import Tuple
2423

25-
import kubernetes.client.models as k8s
24+
from kubernetes.client import models as k8s
2625

2726
from airflow.exceptions import AirflowConfigException
2827
from airflow.kubernetes.k8s_model import K8SModel

airflow/kubernetes/volume.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
"""
1818
Classes for interacting with Kubernetes API
1919
"""
20-
2120
import copy
2221
from typing import Dict
2322

24-
import kubernetes.client.models as k8s
23+
from kubernetes.client import models as k8s
2524

2625
from airflow.kubernetes.k8s_model import K8SModel
2726

airflow/kubernetes/volume_mount.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
"""
1818
Classes for interacting with Kubernetes API
1919
"""
20-
2120
import copy
2221

23-
import kubernetes.client.models as k8s
22+
from kubernetes.client import models as k8s
2423

2524
from airflow.kubernetes.k8s_model import K8SModel
2625

airflow/kubernetes/worker_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import os
1919
from typing import Dict, List
2020

21-
import kubernetes.client.models as k8s
21+
from kubernetes.client import models as k8s
2222

2323
from airflow.configuration import conf
2424
from airflow.kubernetes.k8s_model import append_to_pod

airflow/models/dagcode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ def dag_fileloc_hash(full_filepath: str) -> int:
214214
# Hashing is needed because the length of fileloc is 2000 as an Airflow convention,
215215
# which is over the limit of indexing.
216216
import hashlib
217+
217218
# Only 7 bytes because MySQL BigInteger can hold only 8 bytes (signed).
218219
return struct.unpack('>Q', hashlib.sha1(
219220
full_filepath.encode('utf-8')).digest()[-8:])[0] >> 8

airflow/models/taskinstance.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
1918
import getpass
2019
import hashlib
2120
import logging
@@ -959,8 +958,8 @@ def _run_raw_task(
959958
:param pool: specifies the pool to use to run the task instance
960959
:type pool: str
961960
"""
962-
from airflow.sensors.base_sensor_operator import BaseSensorOperator
963961
from airflow.models.renderedtifields import RenderedTaskInstanceFields as RTIF
962+
from airflow.sensors.base_sensor_operator import BaseSensorOperator
964963

965964
task = self.task
966965
self.test_mode = test_mode

airflow/providers/apache/hdfs/hooks/hdfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from airflow.hooks.base_hook import BaseHook
2222

2323
try:
24-
from snakebite.client import Client, HAClient, Namenode, AutoConfigClient # pylint: disable=syntax-error
24+
from snakebite.client import AutoConfigClient, Client, HAClient, Namenode # pylint: disable=syntax-error
2525
snakebite_loaded = True
2626
except ImportError:
2727
snakebite_loaded = False

airflow/providers/apache/hive/hooks/hive.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
1918
import contextlib
2019
import os
2120
import re
@@ -506,8 +505,8 @@ def get_metastore_client(self):
506505
Returns a Hive thrift client.
507506
"""
508507
import hmsclient
509-
from thrift.transport import TSocket, TTransport
510508
from thrift.protocol import TBinaryProtocol
509+
from thrift.transport import TSocket, TTransport
511510

512511
conn = self._find_valid_server()
513512

airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import re
1919
from typing import Dict, List, Optional, Tuple
2020

21-
import kubernetes.client.models as k8s
21+
from kubernetes.client import models as k8s
2222

2323
from airflow.exceptions import AirflowException
2424
from airflow.kubernetes import kube_client, pod_generator, pod_launcher

airflow/providers/google/cloud/hooks/gcs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,9 @@ def is_older_than(self, bucket_name, object_name, seconds):
475475
"""
476476
blob_update_time = self.get_blob_update_time(bucket_name, object_name)
477477
if blob_update_time is not None:
478-
from airflow.utils import timezone
479478
from datetime import timedelta
479+
480+
from airflow.utils import timezone
480481
current_time = timezone.utcnow()
481482
given_time = current_time - timedelta(seconds=seconds)
482483
self.log.info("Verify object date: %s is older than %s", blob_update_time, given_time)

airflow/providers/hashicorp/_internal_client/vault_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
1817
from typing import List, Optional
1918

2019
import hvac
@@ -268,8 +267,7 @@ def _auth_github(self, _client: hvac.Client) -> None:
268267
def _auth_gcp(self, _client: hvac.Client) -> None:
269268
# noinspection PyProtectedMember
270269
from airflow.providers.google.cloud.utils.credentials_provider import (
271-
get_credentials_and_project_id,
272-
_get_scopes
270+
_get_scopes, get_credentials_and_project_id,
273271
)
274272
scopes = _get_scopes(self.gcp_scopes)
275273
credentials, _ = get_credentials_and_project_id(key_path=self.gcp_key_path,

airflow/sentry.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,9 @@ def flush(self):
161161
try:
162162
# Verify blinker installation
163163
from blinker import signal # noqa: F401 pylint: disable=unused-import
164-
165-
from sentry_sdk.integrations.logging import ignore_logger
164+
from sentry_sdk import add_breadcrumb, capture_exception, configure_scope, init, push_scope
166165
from sentry_sdk.integrations.flask import FlaskIntegration
167-
from sentry_sdk import (
168-
push_scope,
169-
configure_scope,
170-
add_breadcrumb,
171-
init,
172-
capture_exception,
173-
)
166+
from sentry_sdk.integrations.logging import ignore_logger
174167

175168
Sentry = ConfiguredSentry()
176169

airflow/settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
1918
import atexit
2019
import json
2120
import logging
@@ -32,11 +31,12 @@
3231

3332
# noinspection PyUnresolvedReferences
3433
from airflow import api
35-
# pylint: disable=unused-import
36-
from airflow.configuration import AIRFLOW_HOME, WEBSERVER_CONFIG, conf # NOQA F401
3734
from airflow.logging_config import configure_logging
3835
from airflow.utils.orm_event_handlers import setup_event_handlers
3936

37+
# pylint: disable=unused-import
38+
from airflow.configuration import AIRFLOW_HOME, WEBSERVER_CONFIG, conf # NOQA F401
39+
4040
log = logging.getLogger(__name__)
4141

4242

airflow/task/task_runner/standard_task_runner.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ def _start_by_fork(self): # pylint: disable=inconsistent-return-statements
5252
self.log.info("Started process %d to run task", pid)
5353
return psutil.Process(pid)
5454
else:
55+
import signal
56+
57+
from airflow import settings
5558
from airflow.cli.cli_parser import get_parser
5659
from airflow.sentry import Sentry
57-
import signal
58-
import airflow.settings as settings
5960

6061
signal.signal(signal.SIGINT, signal.SIG_DFL)
6162
signal.signal(signal.SIGTERM, signal.SIG_DFL)

airflow/ti_deps/deps/not_previously_skipped_dep.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
1918
from airflow.ti_deps.deps.base_ti_dep import BaseTIDep
2019

2120

@@ -33,10 +32,7 @@ def _get_dep_statuses(
3332
self, ti, session, dep_context
3433
): # pylint: disable=signature-differs
3534
from airflow.models.skipmixin import (
36-
SkipMixin,
37-
XCOM_SKIPMIXIN_KEY,
38-
XCOM_SKIPMIXIN_SKIPPED,
39-
XCOM_SKIPMIXIN_FOLLOWED,
35+
XCOM_SKIPMIXIN_FOLLOWED, XCOM_SKIPMIXIN_KEY, XCOM_SKIPMIXIN_SKIPPED, SkipMixin,
4036
)
4137
from airflow.utils.state import State
4238

airflow/typing_compat.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
# Protocol and TypedDict are only added to typing module starting from
2626
# python 3.8 we can safely remove this shim import after Airflow drops
2727
# support for <3.8
28-
from typing import Protocol, runtime_checkable, TypedDict # type: ignore # noqa # pylint: disable=unused-import
28+
from typing import ( # type: ignore # noqa # pylint: disable=unused-import
29+
Protocol, TypedDict, runtime_checkable,
30+
)
2931
except ImportError:
30-
from typing_extensions import Protocol, runtime_checkable, TypedDict # type: ignore # noqa
32+
from typing_extensions import Protocol, TypedDict, runtime_checkable # type: ignore # noqa

airflow/utils/db.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ def drop_airflow_models(connection):
635635
@return: None
636636
"""
637637
from airflow.models.base import Base
638+
638639
# Drop connection and chart - those tables have been deleted and in case you
639640
# run resetdb on schema with chart or users table will fail
640641
chart = Table('chart', Base.metadata)

airflow/www/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
1918
import json
2019
import time
2120
from urllib.parse import urlencode
2221

23-
import flask_appbuilder.models.sqla.filters as fab_sqlafilters
2422
import markdown
2523
import sqlalchemy as sqla
2624
from flask import Markup, Response, request, url_for
2725
from flask_appbuilder.forms import FieldConverter
26+
from flask_appbuilder.models.sqla import filters as fab_sqlafilters
2827
from flask_appbuilder.models.sqla.interface import SQLAInterface
2928
from pygments import highlight, lexers
3029
from pygments.formatters import HtmlFormatter

airflow/www/views.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818
#
19-
2019
import copy
2120
import itertools
2221
import json
@@ -988,7 +987,7 @@ def run(self):
988987
@action_logging
989988
def delete(self):
990989
from airflow.api.common.experimental import delete_dag
991-
from airflow.exceptions import DagNotFound, DagFileExists
990+
from airflow.exceptions import DagFileExists, DagNotFound
992991

993992
dag_id = request.values.get('dag_id')
994993
origen = request.values.get('origen') or url_for('Airflow.index')

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/apache/airflow/commit/44d4ae809c1e3784ff95b6a5e95113c3412e56b3

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy