Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Can't set attribute error, when trying to use the same name as a Field #41

Closed
rossmacarthur opened this issue Dec 10, 2018 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@rossmacarthur
Copy link
Owner

rossmacarthur commented Dec 10, 2018

How to replicate:

from serde import Model, field

class A(Model):
    derp = field.Field()

class B(A):
    @property
    def derp(self):
        return 'something else'

B()  # does not work

Exception is

serde/model.py", line 284, in __init__
    setattr(self, name, value)
AttributeError: can't set attribute
@rossmacarthur rossmacarthur added the bug Something isn't working label Dec 11, 2018
@rossmacarthur
Copy link
Owner Author

rossmacarthur commented Dec 11, 2018

I think class attributes / methods / properties with the same name as a field should take precedence, and those Fields will be dropped.

rossmacarthur added a commit that referenced this issue Dec 11, 2018
@rossmacarthur
Copy link
Owner Author

Resolved by #42

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant