From 795f24b3e7f9376f91b7468b1279635c5fed4571 Mon Sep 17 00:00:00 2001 From: Dalena Date: Tue, 14 Jan 2025 13:29:21 -0500 Subject: [PATCH] fix: defaultdict --- silverback/cluster/client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/silverback/cluster/client.py b/silverback/cluster/client.py index acaefcc7..2392662b 100644 --- a/silverback/cluster/client.py +++ b/silverback/cluster/client.py @@ -1,3 +1,4 @@ +from collections import defaultdict from datetime import datetime from functools import cache from typing import ClassVar, Literal @@ -299,10 +300,10 @@ def bots(self) -> dict[str, Bot]: def bots_list(self) -> dict[str, list[Bot]]: response = self.get("/bots") handle_error_with_response(response) - bots_dict: dict[str, list[Bot]] = {} + bots_dict = defaultdict(list) for bot in map(Bot.model_validate, response.json()): - bots_dict.setdefault(bot.name, []).append(bot) - return bots_dict + bots_dict[bot.name].append(bot) + return dict(bots_dict) def new_bot( self,