Skip to content

Commit

Permalink
fix: violation of the DRY principle
Browse files Browse the repository at this point in the history
  • Loading branch information
drveles authored and Vasilii Frolov committed Dec 10, 2024
1 parent 0763309 commit 5ded808
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions hello/hello_activity_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,39 +59,22 @@ async def run(self, list: ShoppingList) -> str:
ordered: List[str] = []
for item in list.items:
if item.fruit is Fruit.APPLE:
ordered.append(
await workflow.execute_activity(
order_apples,
item.amount,
start_to_close_timeout=timedelta(seconds=5),
)
)
order_function = order_apples
elif item.fruit is Fruit.BANANA:
ordered.append(
await workflow.execute_activity(
order_bananas,
item.amount,
start_to_close_timeout=timedelta(seconds=5),
)
)
order_function = order_bananas
elif item.fruit is Fruit.CHERRY:
ordered.append(
await workflow.execute_activity(
order_cherries,
item.amount,
start_to_close_timeout=timedelta(seconds=5),
)
)
order_function = order_cherries
elif item.fruit is Fruit.ORANGE:
ordered.append(
await workflow.execute_activity(
order_oranges,
item.amount,
start_to_close_timeout=timedelta(seconds=5),
)
)
order_function = order_oranges
else:
raise ValueError(f"Unrecognized fruit: {item.fruit}")
ordered.append(
await workflow.execute_activity(
order_function,
item.amount,
start_to_close_timeout=timedelta(seconds=5),
)
)
return "".join(ordered)


Expand Down

0 comments on commit 5ded808

Please sign in to comment.