From 2aad67883388d6c2f45d41e704a34e44cde035b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=BChler?= <17296905+buehlefs@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:10:21 +0100 Subject: [PATCH] Fix possible NoneType is not iterable error --- muse_for_music/models/helper_classes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/muse_for_music/models/helper_classes.py b/muse_for_music/models/helper_classes.py index c6cb8da..12e3dbc 100644 --- a/muse_for_music/models/helper_classes.py +++ b/muse_for_music/models/helper_classes.py @@ -225,10 +225,14 @@ def _update_updateable_model_list(self, item_list: Sequence[dict], if to_delete: db.session.expire(self) - def update_list(self, item_list: Union[Sequence[int], Sequence[dict]], + def update_list(self, item_list: Union[Sequence[int], Sequence[dict], None], old_items: Union[Dict[int, K], Dict[int, W]], mapping_cls: Any, item_cls: Type[V] = None, mapping_cls_attribute: str = None): + # consider None an empty list + if item_list is None: + item_list = tuple() + if issubclass(mapping_cls, UpdateableModelMixin): self._update_updateable_model_list(item_list, old_items, mapping_cls) elif issubclass(item_cls, GetByID) and item_cls is not None and mapping_cls_attribute: