Skip to content

Commit d83c0c5

Browse files
hussein-awalaephraimbuddy
authored andcommitted
Use f-string instead of in Airflow core (#33753)
(cherry picked from commit 272b40a)
1 parent e32036e commit d83c0c5

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

airflow/models/baseoperator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ def get_direct_relatives(self, upstream: bool = False) -> Iterable[Operator]:
13791379
return self.downstream_list
13801380

13811381
def __repr__(self):
1382-
return "<Task({self.task_type}): {self.task_id}>".format(self=self)
1382+
return f"<Task({self.task_type}): {self.task_id}>"
13831383

13841384
@property
13851385
def operator_class(self) -> type[BaseOperator]: # type: ignore[override]

airflow/models/dagrun.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,8 @@ def __init__(
232232

233233
def __repr__(self):
234234
return (
235-
"<DagRun {dag_id} @ {execution_date}: {run_id}, state:{state}, "
236-
"queued_at: {queued_at}. externally triggered: {external_trigger}>"
237-
).format(
238-
dag_id=self.dag_id,
239-
execution_date=self.execution_date,
240-
run_id=self.run_id,
241-
state=self.state,
242-
queued_at=self.queued_at,
243-
external_trigger=self.external_trigger,
235+
f"<DagRun {self.dag_id} @ {self.execution_date}: {self.run_id}, state:{self.state}, "
236+
f"queued_at: {self.queued_at}. externally triggered: {self.external_trigger}>"
244237
)
245238

246239
@validates("run_id")

airflow/www/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def check_import_errors(fileloc, session):
197197
).all()
198198
if import_errors:
199199
for import_error in import_errors:
200-
flash("Broken DAG: [{ie.filename}] {ie.stacktrace}".format(ie=import_error), "dag_import_error")
200+
flash(f"Broken DAG: [{import_error.filename}] {import_error.stacktrace}", "dag_import_error")
201201

202202

203203
def check_dag_warnings(dag_id, session):

0 commit comments

Comments
 (0)