Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 4e8f9cc

Browse files
authored
Enable Black - Python Auto Formmatter (apache#9550)
1 parent 1dc7099 commit 4e8f9cc

File tree

1,070 files changed

+15413
-15140
lines changed

Some content is hidden

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

1,070 files changed

+15413
-15140
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ repos:
159159
rev: 20.8b1
160160
hooks:
161161
- id: black
162-
files: api_connexion/.*\.py|.*providers.*\.py|^chart/tests/.*\.py
163-
exclude: .*kubernetes_pod\.py|.*google/common/hooks/base_google\.py$
162+
exclude: .*kubernetes_pod\.py|.*google/common/hooks/base_google\.py$|^airflow/configuration.py$
164163
args: [--config=./pyproject.toml]
165164
- repo: https://github.com/pre-commit/pre-commit-hooks
166165
rev: v3.3.0
@@ -203,7 +202,7 @@ repos:
203202
name: Run isort to sort imports
204203
types: [python]
205204
# To keep consistent with the global isort skip config defined in setup.cfg
206-
exclude: ^build/.*$|^.tox/.*$|^venv/.*$|.*api_connexion/.*\.py|.*providers.*\.py
205+
exclude: ^build/.*$|^.tox/.*$|^venv/.*$
207206
- repo: https://github.com/pycqa/pydocstyle
208207
rev: 5.1.1
209208
hooks:

airflow/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,18 @@ def __getattr__(name):
5555
# PEP-562: Lazy loaded attributes on python modules
5656
if name == "DAG":
5757
from airflow.models.dag import DAG # pylint: disable=redefined-outer-name
58+
5859
return DAG
5960
if name == "AirflowException":
6061
from airflow.exceptions import AirflowException # pylint: disable=redefined-outer-name
62+
6163
return AirflowException
6264
raise AttributeError(f"module {__name__} has no attribute {name}")
6365

6466

6567
if not settings.LAZY_LOAD_PLUGINS:
6668
from airflow import plugins_manager
69+
6770
plugins_manager.ensure_plugins_loaded()
6871

6972

airflow/api/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,5 @@ def load_auth():
3838
log.info("Loaded API auth backend: %s", auth_backend)
3939
return auth_backend
4040
except ImportError as err:
41-
log.critical(
42-
"Cannot import %s for API authentication due to: %s",
43-
auth_backend, err
44-
)
41+
log.critical("Cannot import %s for API authentication due to: %s", auth_backend, err)
4542
raise AirflowException(err)

airflow/api/auth/backend/basic_auth.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ def auth_current_user() -> Optional[User]:
5353

5454
def requires_authentication(function: T):
5555
"""Decorator for functions that require authentication"""
56+
5657
@wraps(function)
5758
def decorated(*args, **kwargs):
5859
if auth_current_user() is not None:
5960
return function(*args, **kwargs)
6061
else:
61-
return Response(
62-
"Unauthorized", 401, {"WWW-Authenticate": "Basic"}
63-
)
62+
return Response("Unauthorized", 401, {"WWW-Authenticate": "Basic"})
6463

6564
return cast(T, decorated)

airflow/api/auth/backend/default.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def init_app(_):
3333

3434
def requires_authentication(function: T):
3535
"""Decorator for functions that require authentication"""
36+
3637
@wraps(function)
3738
def decorated(*args, **kwargs):
3839
return function(*args, **kwargs)

airflow/api/auth/backend/kerberos_auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def _gssapi_authenticate(token):
132132

133133
def requires_authentication(function: T):
134134
"""Decorator for functions that require authentication with Kerberos"""
135+
135136
@wraps(function)
136137
def decorated(*args, **kwargs):
137138
header = request.headers.get("Authorization")
@@ -144,11 +145,11 @@ def decorated(*args, **kwargs):
144145
response = function(*args, **kwargs)
145146
response = make_response(response)
146147
if ctx.kerberos_token is not None:
147-
response.headers['WWW-Authenticate'] = ' '.join(['negotiate',
148-
ctx.kerberos_token])
148+
response.headers['WWW-Authenticate'] = ' '.join(['negotiate', ctx.kerberos_token])
149149

150150
return response
151151
if return_code != kerberos.AUTH_GSS_CONTINUE:
152152
return _forbidden()
153153
return _unauthorized()
154+
154155
return cast(T, decorated)

airflow/api/client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ def get_current_api_client() -> Client:
3535
api_client = api_module.Client(
3636
api_base_url=conf.get('cli', 'endpoint_url'),
3737
auth=getattr(auth_backend, 'CLIENT_AUTH', None),
38-
session=session
38+
session=session,
3939
)
4040
return api_client

airflow/api/client/json_client.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ def _request(self, url, method='GET', json=None):
4545
def trigger_dag(self, dag_id, run_id=None, conf=None, execution_date=None):
4646
endpoint = f'/api/experimental/dags/{dag_id}/dag_runs'
4747
url = urljoin(self._api_base_url, endpoint)
48-
data = self._request(url, method='POST',
49-
json={
50-
"run_id": run_id,
51-
"conf": conf,
52-
"execution_date": execution_date,
53-
})
48+
data = self._request(
49+
url,
50+
method='POST',
51+
json={
52+
"run_id": run_id,
53+
"conf": conf,
54+
"execution_date": execution_date,
55+
},
56+
)
5457
return data['message']
5558

5659
def delete_dag(self, dag_id):
@@ -74,12 +77,15 @@ def get_pools(self):
7477
def create_pool(self, name, slots, description):
7578
endpoint = '/api/experimental/pools'
7679
url = urljoin(self._api_base_url, endpoint)
77-
pool = self._request(url, method='POST',
78-
json={
79-
'name': name,
80-
'slots': slots,
81-
'description': description,
82-
})
80+
pool = self._request(
81+
url,
82+
method='POST',
83+
json={
84+
'name': name,
85+
'slots': slots,
86+
'description': description,
87+
},
88+
)
8389
return pool['pool'], pool['slots'], pool['description']
8490

8591
def delete_pool(self, name):

airflow/api/client/local_client.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ class Client(api_client.Client):
2626
"""Local API client implementation."""
2727

2828
def trigger_dag(self, dag_id, run_id=None, conf=None, execution_date=None):
29-
dag_run = trigger_dag.trigger_dag(dag_id=dag_id,
30-
run_id=run_id,
31-
conf=conf,
32-
execution_date=execution_date)
29+
dag_run = trigger_dag.trigger_dag(
30+
dag_id=dag_id, run_id=run_id, conf=conf, execution_date=execution_date
31+
)
3332
return f"Created {dag_run}"
3433

3534
def delete_dag(self, dag_id):

airflow/api/common/experimental/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ def check_and_get_dag(dag_id: str, task_id: Optional[str] = None) -> DagModel:
2929
if dag_model is None:
3030
raise DagNotFound(f"Dag id {dag_id} not found in DagModel")
3131

32-
dagbag = DagBag(
33-
dag_folder=dag_model.fileloc,
34-
read_dags_from_db=True
35-
)
32+
dagbag = DagBag(dag_folder=dag_model.fileloc, read_dags_from_db=True)
3633
dag = dagbag.get_dag(dag_id)
3734
if not dag:
3835
error_message = f"Dag id {dag_id} not found"
@@ -47,7 +44,6 @@ def check_and_get_dagrun(dag: DagModel, execution_date: datetime) -> DagRun:
4744
"""Get DagRun object and check that it exists"""
4845
dagrun = dag.get_dagrun(execution_date=execution_date)
4946
if not dagrun:
50-
error_message = ('Dag Run for date {} not found in dag {}'
51-
.format(execution_date, dag.dag_id))
47+
error_message = f'Dag Run for date {execution_date} not found in dag {dag.dag_id}'
5248
raise DagRunNotFound(error_message)
5349
return dagrun

0 commit comments

Comments
 (0)