Superbird11/ranges

Unhashable data types not allowed as values of RangeDict

alexgawrilow opened this issue · 0 comments

Not sure if that behaviour is intended, but using unhashable data types as values of RangeDict raises TypeError.
Example:

x = RangeDict({Range(0, 1), ["A", "B"]})

Output:

----> 1 x = RangeDict({Range(0, 1), ["A", "B"]})

TypeError: unhashable type: 'list'

Assigning an unhashable data type to a key of RangeDict raises TypeError, as well (from the add-method).

y = RangeDict()
y[Range(0, 1)] = ["A", "B"]

Output:

----> 2 y[Range(0, 1)] = ["A", "B"]

~venv/lib/python3.6/site-packages/ranges/ranges.py in __setitem__(self, key, value)
   1733 
   1734     def __setitem__(self, key, value):
-> 1735         self.add(key, value)
   1736 
   1737     def __getitem__(self, item):

~venv/lib/python3.6/site-packages/ranges/ranges.py in add(self, rng, value)
   1299                 break
   1300         # then, add it back in depending on whether it shares an existing value or not.
-> 1301         if value in self._values:
   1302             # duplicate value. More than one range must map to it.
   1303             existing_rangesets = self._values[value]

TypeError: unhashable type: 'list'