Skip to content

Decorated functions do not work with inheritance #1549

@LecrisUT

Description

@LecrisUT

I was trying to research how to get the class bound method instead of the function in a decorator and was looking at attrs if it figured it out, but apparently not

>>> import attrs

... @attrs.define
... class A:
...     foo: str = attrs.field()
... 
...     @foo.default
...     def _foo_default(self):
...         return "A"
... 
... @attrs.define
... class B(A):
...     def _foo_default(self):
...         return "B"
... print(A())
... print(B())
A(foo='A')
B(foo='A')  # was expecting `foo='B'` here due to overriding

Have you guys researched this topic and is there any conclusions on this?

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