Skip to content

17.1.0 apparently breaks asdict #192

@pauloalem

Description

@pauloalem

Hello there!
I have upgraded to 17.1.0 and aparently it breaks down on asdict convertion.
I've got this utility validator optional_instance_of that ends up raising a

return hash(_attrs_to_tuple(self, attrs))
TypeError: unhashable type: '_OptionalValidator'

Here's a sample to trigger that behavior:

import attr


def optional_instance_of(of):
    return attr.validators.optional(attr.validators.instance_of(of))


@attr.s()
class A:
    a = attr.ib(default=None, validator=optional_instance_of(int))

a = A()
print(attr.asdict(a, filter=attr.filters.exclude(type(None))))

Is this related to #142 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions