When a key contains the same string as previous key error below is thrown.
$ python test.py
Traceback (most recent call last):
File "test.py", line 8, in <module>
flatten = flatdict.FlatterDict(data, delimiter='_').items()
File "/home/ctran/.venv/24x7/lib/python3.8/site-packages/flatdict.py", line 389, in __init__
super(FlatterDict, self).__init__(value, delimiter, dict_class)
File "/home/ctran/.venv/24x7/lib/python3.8/site-packages/flatdict.py", line 29, in __init__
self.update(value)
File "/home/ctran/.venv/24x7/lib/python3.8/site-packages/flatdict.py", line 356, in update
[self.__setitem__(k, v) for k, v in dict(other or kwargs).items()]
File "/home/ctran/.venv/24x7/lib/python3.8/site-packages/flatdict.py", line 356, in <listcomp>
[self.__setitem__(k, v) for k, v in dict(other or kwargs).items()]
File "/home/ctran/.venv/24x7/lib/python3.8/site-packages/flatdict.py", line 422, in __setitem__
self._values[pk][ck] = value
File "/home/ctran/.venv/24x7/lib/python3.8/site-packages/flatdict.py", line 420, in __setitem__
raise TypeError(
TypeError: Assignment to invalid type for key key
Problem
When a key contains the same string as previous key error below is thrown.
Sample code
Observed behaviors
When data is like below, error above is throw.
However, if data is below error isn't thrown but only
first_key
is returned. Keyfirst_key_again
is gone from the result.