From f38a1edda62ec02cdda41f09e99f8681fb79debc Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Mon, 2 Dec 2024 20:39:34 +0800 Subject: [PATCH] Avoid lambda assignments (#44563) --- airflow/serialization/serialized_objects.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/airflow/serialization/serialized_objects.py b/airflow/serialization/serialized_objects.py index f78a2b78b8811..66b24b0ad40a9 100644 --- a/airflow/serialization/serialized_objects.py +++ b/airflow/serialization/serialized_objects.py @@ -390,9 +390,12 @@ def encode_start_trigger_args(var: StartTriggerArgs) -> dict[str, Any]: :meta private: """ - serialize_kwargs = lambda key: ( - BaseSerialization.serialize(getattr(var, key)) if getattr(var, key) is not None else None - ) + + def serialize_kwargs(key: str) -> Any: + if (val := getattr(var, key)) is None: + return None + return BaseSerialization.serialize(val) + return { "__type": "START_TRIGGER_ARGS", "trigger_cls": var.trigger_cls, @@ -409,7 +412,11 @@ def decode_start_trigger_args(var: dict[str, Any]) -> StartTriggerArgs: :meta private: """ - deserialize_kwargs = lambda key: BaseSerialization.deserialize(var[key]) if var[key] is not None else None + + def deserialize_kwargs(key: str) -> Any: + if (val := var[key]) is None: + return None + return BaseSerialization.deserialize(val) return StartTriggerArgs( trigger_cls=var["trigger_cls"],