Skip to content

Commit 41bf172

Browse files
authored
Simplify string expressions (#12093)
1 parent 7597f3a commit 41bf172

File tree

90 files changed

+196
-214
lines changed

Some content is hidden

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

90 files changed

+196
-214
lines changed

β€Žairflow/contrib/operators/gcs_to_gdrive_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from airflow.providers.google.suite.transfers.gcs_to_gdrive import GCSToGoogleDriveOperator # noqa
2424

2525
warnings.warn(
26-
"This module is deprecated. " "Please use `airflow.providers.google.suite.transfers.gcs_to_gdrive.",
26+
"This module is deprecated. Please use `airflow.providers.google.suite.transfers.gcs_to_gdrive.",
2727
DeprecationWarning,
2828
stacklevel=2,
2929
)

β€Žairflow/executors/kubernetes_executor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def run(self) -> None:
170170
)
171171
except ReadTimeoutError:
172172
self.log.warning(
173-
"There was a timeout error accessing the Kube API. " "Retrying request.", exc_info=True
173+
"There was a timeout error accessing the Kube API. Retrying request.", exc_info=True
174174
)
175175
time.sleep(1)
176176
except Exception:
@@ -736,7 +736,7 @@ def adopt_launched_task(self, kube_client, pod, pod_ids: dict):
736736
pod_id = create_pod_id(dag_id=dag_id, task_id=task_id)
737737
if pod_id not in pod_ids:
738738
self.log.error(
739-
"attempting to adopt task %s in dag %s" " which was not specified by database",
739+
"attempting to adopt task %s in dag %s which was not specified by database",
740740
task_id,
741741
dag_id,
742742
)

β€Žairflow/jobs/scheduler_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def manage_slas(self, dag: DAG, session: Session = None) -> None:
509509
notification_sent = True
510510
except Exception: # pylint: disable=broad-except
511511
Stats.incr('sla_email_notification_failure')
512-
self.log.exception("Could not send SLA Miss email notification for" " DAG %s", dag.dag_id)
512+
self.log.exception("Could not send SLA Miss email notification for DAG %s", dag.dag_id)
513513
# If we sent any notification, update the sla_miss table
514514
if notification_sent:
515515
for sla in slas:

β€Žairflow/kubernetes/pod_generator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ def __init__( # pylint: disable=too-many-arguments,too-many-locals
132132
):
133133
if not pod_template_file and not pod:
134134
raise AirflowConfigException(
135-
"Podgenerator requires either a " "`pod` or a `pod_template_file` argument"
135+
"Podgenerator requires either a `pod` or a `pod_template_file` argument"
136136
)
137137
if pod_template_file and pod:
138-
raise AirflowConfigException("Cannot pass both `pod` " "and `pod_template_file` arguments")
138+
raise AirflowConfigException("Cannot pass both `pod` and `pod_template_file` arguments")
139139

140140
if pod_template_file:
141141
self.ud_pod = self.deserialize_model_file(pod_template_file)
@@ -199,7 +199,7 @@ def from_obj(obj) -> Optional[Union[dict, k8s.V1Pod]]:
199199
return PodGenerator.from_legacy_obj(obj)
200200
else:
201201
raise TypeError(
202-
'Cannot convert a non-kubernetes.client.models.V1Pod' 'object into a KubernetesExecutorConfig'
202+
'Cannot convert a non-kubernetes.client.models.V1Pod object into a KubernetesExecutorConfig'
203203
)
204204

205205
@staticmethod

β€Žairflow/kubernetes/pod_launcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def run_pod_async(self, pod: V1Pod, **kwargs):
8383
)
8484
self.log.debug('Pod Creation Response: %s', resp)
8585
except Exception as e:
86-
self.log.exception('Exception when attempting ' 'to create Namespaced Pod: %s', json_pod)
86+
self.log.exception('Exception when attempting to create Namespaced Pod: %s', json_pod)
8787
raise e
8888
return resp
8989

β€Žairflow/models/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def log_info(self):
337337
DeprecationWarning,
338338
stacklevel=2,
339339
)
340-
return "id: {}. Host: {}, Port: {}, Schema: {}, " "Login: {}, Password: {}, extra: {}".format(
340+
return "id: {}. Host: {}, Port: {}, Schema: {}, Login: {}, Password: {}, extra: {}".format(
341341
self.conn_id,
342342
self.host,
343343
self.port,
@@ -358,7 +358,7 @@ def debug_info(self):
358358
DeprecationWarning,
359359
stacklevel=2,
360360
)
361-
return "id: {}. Host: {}, Port: {}, Schema: {}, " "Login: {}, Password: {}, extra: {}".format(
361+
return "id: {}. Host: {}, Port: {}, Schema: {}, Login: {}, Password: {}, extra: {}".format(
362362
self.conn_id,
363363
self.host,
364364
self.port,

β€Žairflow/models/dag.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ def clear(
13041304
if confirm_prompt:
13051305
ti_list = "\n".join([str(t) for t in tis])
13061306
question = (
1307-
"You are about to delete these {count} tasks:\n" "{ti_list}\n\n" "Are you sure? (yes/no): "
1307+
"You are about to delete these {count} tasks:\n{ti_list}\n\nAre you sure? (yes/no): "
13081308
).format(count=count, ti_list=ti_list)
13091309
do_it = utils.helpers.ask_yesno(question)
13101310

@@ -1367,9 +1367,7 @@ def clear_dags(
13671367
return 0
13681368
if confirm_prompt:
13691369
ti_list = "\n".join([str(t) for t in all_tis])
1370-
question = (
1371-
"You are about to delete these {} tasks:\n" "{}\n\n" "Are you sure? (yes/no): "
1372-
).format(count, ti_list)
1370+
question = f"You are about to delete these {count} tasks:\n{ti_list}\n\nAre you sure? (yes/no): "
13731371
do_it = utils.helpers.ask_yesno(question)
13741372

13751373
if do_it:

β€Žairflow/models/dagbag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def size(self) -> int:
139139
def store_serialized_dags(self) -> bool:
140140
"""Whether or not to read dags from DB"""
141141
warnings.warn(
142-
"The store_serialized_dags property has been deprecated. " "Use read_dags_from_db instead.",
142+
"The store_serialized_dags property has been deprecated. Use read_dags_from_db instead.",
143143
DeprecationWarning,
144144
stacklevel=2,
145145
)

β€Žairflow/models/dagrun.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,15 +599,13 @@ def verify_integrity(self, session: Session = None):
599599
if ti.state == State.REMOVED:
600600
pass # ti has already been removed, just ignore it
601601
elif self.state is not State.RUNNING and not dag.partial:
602-
self.log.warning(
603-
"Failed to get task '%s' for dag '%s'. " "Marking it as removed.", ti, dag
604-
)
602+
self.log.warning("Failed to get task '%s' for dag '%s'. Marking it as removed.", ti, dag)
605603
Stats.incr(f"task_removed_from_dag.{dag.dag_id}", 1, 1)
606604
ti.state = State.REMOVED
607605

608606
should_restore_task = (task is not None) and ti.state == State.REMOVED
609607
if should_restore_task:
610-
self.log.info("Restoring task '%s' which was previously " "removed from DAG '%s'", ti, dag)
608+
self.log.info("Restoring task '%s' which was previously removed from DAG '%s'", ti, dag)
611609
Stats.incr(f"task_restored_to_dag.{dag.dag_id}", 1, 1)
612610
ti.state = State.NONE
613611
session.merge(ti)

β€Žairflow/models/serialized_dag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def read_all_dags(cls, session: Session = None) -> Dict[str, 'SerializedDAG']:
155155
dags[row.dag_id] = dag
156156
else:
157157
log.warning(
158-
"dag_id Mismatch in DB: Row with dag_id '%s' has Serialised DAG " "with '%s' dag_id",
158+
"dag_id Mismatch in DB: Row with dag_id '%s' has Serialised DAG with '%s' dag_id",
159159
row.dag_id,
160160
dag.dag_id,
161161
)
@@ -192,7 +192,7 @@ def remove_deleted_dags(cls, alive_dag_filelocs: List[str], session=None):
192192
alive_fileloc_hashes = [DagCode.dag_fileloc_hash(fileloc) for fileloc in alive_dag_filelocs]
193193

194194
log.debug(
195-
"Deleting Serialized DAGs (for which DAG files are deleted) " "from %s table ", cls.__tablename__
195+
"Deleting Serialized DAGs (for which DAG files are deleted) from %s table ", cls.__tablename__
196196
)
197197

198198
# pylint: disable=no-member

0 commit comments

Comments
 (0)