Skip to content

Using slots class overrides custom __setattr__ in 20.1.0 #680

@pganssle

Description

@pganssle

In 19.3.0, it was possible to have a custom __setattr__ on your slots class, but in 20.1.0 the custom __setattr__ is replaced with the default one:

import attr
@attr.s(slots=True)
class A:
    def __setattr__(self, key, value):
        print(f"{key}: {value}")

In 19.3.0:

>>> A().a = 3
a: 3

In 20.1.0:

>>> A().a = 3
AttributeError: 'A' object has no attribute 'a'
>>> A.__setattr__
<slot wrapper '__setattr__' of 'object' objects>

When slots=False, the same thing does not occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions