Skip to content

Commit

Permalink
fix new suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
bleudev committed Jun 7, 2024
1 parent 755e960 commit f639df4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_udict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions ufpy/udict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit f639df4

Please sign in to comment.