Skip to content

Commit

Permalink
[AIRFLOW-5362] Reorder imports (apache#5944)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinYang21 authored and kaxil committed Oct 2, 2019
1 parent 4dd24a2 commit d719e1f
Show file tree
Hide file tree
Showing 773 changed files with 1,842 additions and 2,338 deletions.
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,19 @@ repos:
entry: "./scripts/ci/pre_commit_pylint_tests.sh"
files: ^tests/.*\.py$
pass_filenames: true
- id: isort
name: Run isort to sort imports
language: python
entry: isort
files: \.py$
# To keep consistent with the global isort skip config defined in setup.cfg
exclude: ^airflow/_vendor/.*$|^build/.*$|^.tox/.*$|^venv/.*$
additional_dependencies: ['isort']
- id: flake8
name: Run flake8
language: system
entry: "./scripts/ci/pre_commit_flake8.sh"
files: \.py$
pass_filenames: true
args:
- --isort-show-traceback
33 changes: 17 additions & 16 deletions airflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,41 @@
implement their own login mechanisms by providing an `airflow_login` module
in their PYTHONPATH. airflow_login should be based off the
`airflow.www.login`
"""
from typing import Optional, Callable
from airflow import version
from airflow.utils.log.logging_mixin import LoggingMixin

__version__ = version.version

import sys
isort:skip_file
"""

# flake8: noqa: F401
from typing import Callable, Optional

from airflow import settings
from airflow import version
from airflow.utils.log.logging_mixin import LoggingMixin
from airflow.configuration import conf
from airflow.models import DAG
from airflow.exceptions import AirflowException
from airflow.models import DAG


__version__ = version.version

settings.initialize()

login = None # type: Optional[Callable]

from airflow import executors
from airflow import hooks
from airflow import macros
from airflow import operators
from airflow import sensors


class AirflowMacroPlugin:
def __init__(self, namespace):
self.namespace = namespace


from airflow import operators # noqa: E402
from airflow import sensors # noqa: E402
from airflow import hooks # noqa: E402
from airflow import executors # noqa: E402
from airflow import macros # noqa: E402

operators._integrate_plugins()
sensors._integrate_plugins() # noqa: E402
sensors._integrate_plugins()
hooks._integrate_plugins()
executors._integrate_plugins()
macros._integrate_plugins()
3 changes: 1 addition & 2 deletions airflow/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@

from importlib import import_module

from airflow.exceptions import AirflowException, AirflowConfigException
from airflow.configuration import conf

from airflow.exceptions import AirflowConfigException, AirflowException
from airflow.utils.log.logging_mixin import LoggingMixin


Expand Down
3 changes: 2 additions & 1 deletion airflow/api/auth/backend/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
# specific language governing permissions and limitations
# under the License.
"""Default authentication backend - everything is allowed"""
from typing import Optional
from functools import wraps
from typing import Optional

from airflow.typing import Protocol


Expand Down
5 changes: 3 additions & 2 deletions airflow/api/auth/backend/deny_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
# specific language governing permissions and limitations
# under the License.
"""Authentication backend that denies all requests"""
from typing import Optional
from functools import wraps
from typing import Optional

from flask import Response
from airflow.api.auth.backend.default import ClientAuthProtocol

from airflow.api.auth.backend.default import ClientAuthProtocol

CLIENT_AUTH = None # type: Optional[ClientAuthProtocol]

Expand Down
12 changes: 2 additions & 10 deletions airflow/api/auth/backend/kerberos_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,17 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Kerberos authentication module"""
import os

from functools import wraps
from socket import getfqdn

from flask import Response
# noinspection PyProtectedMember
from flask import _request_ctx_stack as stack # type: ignore
from flask import make_response
from flask import request
from flask import g

import kerberos

# noinspection PyProtectedMember
from flask import Response, _request_ctx_stack as stack, g, make_response, request # type: ignore
from requests_kerberos import HTTPKerberosAuth

from airflow.configuration import conf
from airflow.utils.log.logging_mixin import LoggingMixin


# pylint: disable=c-extension-no-member
CLIENT_AUTH = HTTPKerberosAuth(service='airflow')

Expand Down
4 changes: 1 addition & 3 deletions airflow/api/client/local_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
"""Local client API"""

from airflow.api.client import api_client
from airflow.api.common.experimental import pool
from airflow.api.common.experimental import trigger_dag
from airflow.api.common.experimental import delete_dag
from airflow.api.common.experimental import delete_dag, pool, trigger_dag


class Client(api_client.Client):
Expand Down
2 changes: 1 addition & 1 deletion airflow/api/common/experimental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from datetime import datetime
from typing import Optional

from airflow.exceptions import DagNotFound, TaskNotFound, DagRunNotFound
from airflow.exceptions import DagNotFound, DagRunNotFound, TaskNotFound
from airflow.models import DagBag, DagModel, DagRun


Expand Down
4 changes: 2 additions & 2 deletions airflow/api/common/experimental/delete_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
from sqlalchemy import or_

from airflow import models
from airflow.models import TaskFail, DagModel
from airflow.utils.db import provide_session
from airflow.exceptions import DagNotFound
from airflow.models import DagModel, TaskFail
from airflow.utils.db import provide_session


@provide_session
Expand Down
2 changes: 1 addition & 1 deletion airflow/api/common/experimental/get_dag_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# specific language governing permissions and limitations
# under the License.
"""DAG runs APIs."""
from typing import Optional, List, Dict, Any
from typing import Any, Dict, List, Optional

from flask import url_for

Expand Down
6 changes: 3 additions & 3 deletions airflow/api/common/experimental/trigger_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"""Triggering DAG runs APIs."""
import json
from datetime import datetime
from typing import Union, Optional, List
from typing import List, Optional, Union

from airflow.exceptions import DagRunAlreadyExists, DagNotFound
from airflow.models import DagRun, DagBag, DagModel
from airflow.exceptions import DagNotFound, DagRunAlreadyExists
from airflow.models import DagBag, DagModel, DagRun
from airflow.utils import timezone
from airflow.utils.state import State

Expand Down
3 changes: 2 additions & 1 deletion airflow/bin/airflow
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
# specific language governing permissions and limitations
# under the License.
import os

import argcomplete

from airflow.configuration import conf
from airflow.bin.cli import CLIFactory
from airflow.configuration import conf

if __name__ == '__main__':

Expand Down
58 changes: 25 additions & 33 deletions airflow/bin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,49 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import argparse
import errno
import functools
import getpass
import importlib
import json
import logging

import os
import subprocess
import textwrap
import random
import string
from importlib import import_module
import functools

import getpass
import re
import reprlib
import argparse
from argparse import RawTextHelpFormatter

from airflow.utils.dot_renderer import render_dag
from airflow.utils.timezone import parse as parsedate
import json
from tabulate import tabulate

import daemon
from daemon.pidfile import TimeoutPIDLockFile
import signal
import string
import subprocess
import sys
import textwrap
import threading
import traceback
import time
import psutil
import re
from urllib.parse import urlunparse
import traceback
from argparse import RawTextHelpFormatter
from importlib import import_module
from typing import Any
from urllib.parse import urlunparse

import daemon
import psutil
from daemon.pidfile import TimeoutPIDLockFile
from sqlalchemy.orm import exc
from tabulate import tabulate

import airflow
from airflow import api
from airflow import jobs, settings
from airflow import api, jobs, settings
from airflow.configuration import conf
from airflow.exceptions import AirflowException, AirflowWebServerTimeout
from airflow.executors import get_default_executor
from airflow.models import (
Connection, DagModel, DagBag, DagPickle, TaskInstance, DagRun, Variable, DAG
)
from airflow.ti_deps.dep_context import (DepContext, SCHEDULER_QUEUED_DEPS)
from airflow.models import DAG, Connection, DagBag, DagModel, DagPickle, DagRun, TaskInstance, Variable
from airflow.ti_deps.dep_context import SCHEDULER_QUEUED_DEPS, DepContext
from airflow.utils import cli as cli_utils, db
from airflow.utils.dot_renderer import render_dag
from airflow.utils.log.logging_mixin import LoggingMixin, redirect_stderr, redirect_stdout
from airflow.utils.net import get_hostname
from airflow.utils.log.logging_mixin import (LoggingMixin, redirect_stderr,
redirect_stdout)
from airflow.www.app import cached_app, create_app, cached_appbuilder

from sqlalchemy.orm import exc
from airflow.utils.timezone import parse as parsedate
from airflow.www.app import cached_app, cached_appbuilder, create_app

api.load_auth()
api_module = import_module(conf.get('cli', 'api_client')) # type: Any
Expand Down
2 changes: 1 addition & 1 deletion airflow/config_templates/airflow_local_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# under the License.

import os
from typing import Dict, Any
from typing import Any, Dict

from airflow.configuration import conf
from airflow.utils.file import mkdirs
Expand Down
5 changes: 4 additions & 1 deletion airflow/config_templates/default_webserver_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
# under the License.
"""Default configuration for the Airflow webserver"""
import os

from flask_appbuilder.security.manager import AUTH_DB

from airflow.configuration import conf

# from flask_appbuilder.security.manager import AUTH_LDAP
# from flask_appbuilder.security.manager import AUTH_OAUTH
# from flask_appbuilder.security.manager import AUTH_OID
# from flask_appbuilder.security.manager import AUTH_REMOTE_USER

from airflow.configuration import conf

basedir = os.path.abspath(os.path.dirname(__file__))

Expand Down
6 changes: 3 additions & 3 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
# specific language governing permissions and limitations
# under the License.

from base64 import b64encode
from collections import OrderedDict
import copy
import os
import pathlib
import shlex
import subprocess
import sys
import warnings
from base64 import b64encode
from collections import OrderedDict
# Ignored Mypy on configparser because it thinks the configparser module has no _UNSET attribute
from configparser import ConfigParser, _UNSET, NoOptionError, NoSectionError # type: ignore
from configparser import _UNSET, ConfigParser, NoOptionError, NoSectionError # type: ignore

from zope.deprecation import deprecated

Expand Down
7 changes: 2 additions & 5 deletions airflow/contrib/auth/backends/github_enterprise_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
# specific language governing permissions and limitations
# under the License.
import flask_login

from flask import redirect, request, url_for
# Need to expose these downstream
# flake8: noqa: F401
from flask_login import current_user, logout_user, login_required, login_user

from flask import url_for, redirect, request

from flask_login import current_user, login_required, login_user, logout_user
from flask_oauthlib.client import OAuth

from airflow import models
Expand Down
7 changes: 2 additions & 5 deletions airflow/contrib/auth/backends/google_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
# specific language governing permissions and limitations
# under the License.
import flask_login

from flask import redirect, request, url_for
# Need to expose these downstream
# flake8: noqa: F401
from flask_login import current_user, logout_user, login_required, login_user

from flask import url_for, redirect, request

from flask_login import current_user, login_required, login_user, logout_user
from flask_oauthlib.client import OAuth

from airflow import models
Expand Down
Loading

0 comments on commit d719e1f

Please sign in to comment.