From 9a51b3509a122ab9b85e6cba04a903cf4f337a02 Mon Sep 17 00:00:00 2001 From: Hussein Awala Date: Sat, 26 Aug 2023 03:39:13 +0200 Subject: [PATCH] E731: replace lambda by a def method in Airflow core --- airflow/cli/cli_config.py | 5 ++++- airflow/cli/commands/connection_command.py | 5 ++++- airflow/www/views.py | 10 ++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/airflow/cli/cli_config.py b/airflow/cli/cli_config.py index c06bd32d96cbb..c52dd9aa90e56 100644 --- a/airflow/cli/cli_config.py +++ b/airflow/cli/cli_config.py @@ -103,7 +103,10 @@ def add_to_parser(self, parser: argparse.ArgumentParser): """Add this argument to an ArgumentParser.""" if "metavar" in self.kwargs and "type" not in self.kwargs: if self.kwargs["metavar"] == "DIRPATH": - type = lambda x: self._is_valid_directory(parser, x) + + def type(x): + return self._is_valid_directory(parser, x) + self.kwargs["type"] = type parser.add_argument(*self.flags, **self.kwargs) diff --git a/airflow/cli/commands/connection_command.py b/airflow/cli/commands/connection_command.py index e32abda1f8ae0..fe9e71733c083 100644 --- a/airflow/cli/commands/connection_command.py +++ b/airflow/cli/commands/connection_command.py @@ -114,7 +114,10 @@ def create_default_connections(args): def _format_connections(conns: list[Connection], file_format: str, serialization_format: str) -> str: if serialization_format == "json": - serializer_func = lambda x: json.dumps(_connection_to_dict(x)) + + def serializer_func(x): + return json.dumps(_connection_to_dict(x)) + elif serialization_format == "uri": serializer_func = Connection.get_uri else: diff --git a/airflow/www/views.py b/airflow/www/views.py index 275432f9bcfa5..59828d82769d1 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -319,9 +319,15 @@ def dag_to_grid(dag: DagModel, dag_runs: Sequence[DagRun], session: Session): sort_order = conf.get("webserver", "grid_view_sorting_order", fallback="topological") if sort_order == "topological": - sort_children_fn = lambda task_group: task_group.topological_sort() + + def sort_children_fn(task_group): + return task_group.topological_sort() + elif sort_order == "hierarchical_alphabetical": - sort_children_fn = lambda task_group: task_group.hierarchical_alphabetical_sort() + + def sort_children_fn(task_group): + return task_group.hierarchical_alphabetical_sort() + else: raise AirflowConfigException(f"Unsupported grid_view_sorting_order: {sort_order}")