From f639df48733fda8f6f7c13a8e1606f2f3e46591b Mon Sep 17 00:00:00 2001 From: bleudev Date: Sat, 8 Jun 2024 00:06:32 +0300 Subject: [PATCH] fix new suggestions --- tests/test_udict.py | 5 +++++ ufpy/udict.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/tests/test_udict.py b/tests/test_udict.py index 1533c46..53251aa 100644 --- a/tests/test_udict.py +++ b/tests/test_udict.py @@ -9,7 +9,12 @@ def test_init(self): d2 = UDict({'hello': 1, 'hi': 'world'}) d3 = UDict() self.assertEqual(d.default, 10) + self.assertEqual(d2.default, None) + self.assertEqual(d3.default, None) + self.assertDictEqual(d.dictionary, d2.dictionary) + self.assertDictEqual(d3.dictionary, {}) + self.assertEqual(d, d2) self.assertNotEqual(d, d3) self.assertNotEqual(d2, d3) diff --git a/ufpy/udict.py b/ufpy/udict.py index 3258e57..f5faa58 100644 --- a/ufpy/udict.py +++ b/ufpy/udict.py @@ -145,6 +145,8 @@ def __getitem__(self, key: KT | int | slice) -> UDict[KT, VT, DV] | VT: def __setitem__(self, key: KT | int | slice, value: VT | list[VT]) -> None: keys = self.__get_keys_from_slice_or_int(key) + + # Ensure 'values' is always a list for consistent processing values = value if isinstance(value, (list, tuple)) else [value] if len(keys) > len(values):