Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid lambda assignments #44563

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions airflow/serialization/serialized_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,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,
Expand All @@ -391,7 +394,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"],
Expand Down