Hey, I ran into some surprising behavior when using attr.asdict() with a frozen set.
I was expecting retain_collection_types=False to convert a frozenset to a list, as it does with a tuple or list, but it keeps it as a frozenset
Example
import attr
@attr.s
class Foo:
bar = attr.ib()
DATA = (1, 2, 3)
print("set:", attr.asdict(Foo(set(DATA))))
print("frozenset", attr.asdict(Foo(frozenset(DATA))))
Output:
$ python attr_demo.py
set: {'bar': [1, 2, 3]}
frozenset {'bar': frozenset({1, 2, 3})}
Expected Output
$ python attr_demo.py
set: {'bar': [1, 2, 3]}
frozenset {'bar': [1, 2, 3]}
it looks like the code change is adding frozenset to the isinstance check on https://github.com/python-attrs/attrs/blob/master/src/attr/_funcs.py#L55
Hey, I ran into some surprising behavior when using
attr.asdict()with a frozen set.I was expecting
retain_collection_types=Falseto convert a frozenset to a list, as it does with a tuple or list, but it keeps it as a frozensetExample
Output:
$ python attr_demo.py set: {'bar': [1, 2, 3]} frozenset {'bar': frozenset({1, 2, 3})}Expected Output
$ python attr_demo.py set: {'bar': [1, 2, 3]} frozenset {'bar': [1, 2, 3]}it looks like the code change is adding
frozensetto theisinstancecheck on https://github.com/python-attrs/attrs/blob/master/src/attr/_funcs.py#L55