Would it make sense to add `set` to `ARRAY_TYPES`?
oittaa opened this issue · 1 comments
oittaa commented
What do you think? For example people might have a list and then cast it as a set to remove duplicates.
tomli_w/_writer.py
ARRAY_TYPES = (list, set, tuple)
tests/test_types.py
def test_set():
obj = {"test-set": {1, 2, 3}}
assert (
tomli_w.dumps(obj)
== """\
test-set = [
1,
2,
3,
]
"""
)
hukkin commented
I think I'd prefer not doing this.
list
and tuple
are intuitive to me because they are ordered, so are TOML arrays. A set
is unordered. E.g. in your test case there's no way of guaranteeing that the order is what you have in the expected TOML string.
E.g. json.dumps
from the standard library also errors on set
s.