Skip to content

Commit

Permalink
Use if block for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
karenbraganz authored and eladkal committed Aug 1, 2024
1 parent 10ee46d commit 50c7415
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
9 changes: 3 additions & 6 deletions airflow/decorators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,9 @@ def _expand(self, expand_input: ExpandInput, *, strict: bool) -> XComArg:
if partial_kwargs.get("pool") is None:
partial_kwargs["pool"] = Pool.DEFAULT_POOL_NAME
if partial_kwargs.get("pool_slots") and partial_kwargs["pool_slots"] < 1:
dag_str = (
f""" in dag {partial_kwargs['dag'].dag_id
}"""
if partial_kwargs.get("dag")
else ""
)
dag_str = ""
if partial_kwargs.get("dag"):
dag_str = f" in dag {partial_kwargs['dag'].dag_id}"
raise ValueError(f"pool slots for {task_id}{dag_str} cannot be less than 1")
partial_kwargs["retries"] = parse_retries(partial_kwargs.get("retries", DEFAULT_RETRIES))
partial_kwargs["retry_delay"] = coerce_timedelta(
Expand Down
9 changes: 3 additions & 6 deletions airflow/models/baseoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,9 @@ def partial(
if partial_kwargs["pool"] is None:
partial_kwargs["pool"] = Pool.DEFAULT_POOL_NAME
if partial_kwargs["pool_slots"] < 1:
dag_str = (
f""" in dag {partial_kwargs['dag'].dag_id
}"""
if partial_kwargs["dag"]
else ""
)
dag_str = ""
if partial_kwargs["dag"]:
dag_str = f" in dag {partial_kwargs['dag'].dag_id}"
raise ValueError(f"pool slots for {partial_kwargs['task_id']}{dag_str} cannot be less than 1")
partial_kwargs["retries"] = parse_retries(partial_kwargs["retries"])
partial_kwargs["retry_delay"] = coerce_timedelta(partial_kwargs["retry_delay"], key="retry_delay")
Expand Down

0 comments on commit 50c7415

Please sign in to comment.