Skip to content

Support for multi-level inheritance #24

@cournape

Description

@cournape

I was quite excited to see characteristic improved to use descriptors, but I was surprised by following behaviour:

from attr import attributes, attr
@attributes
class A(object):
    a = attr()
@attributes
class B(A):
    b = attr()
@attributes
class C(B):
    c = attr()

raises a syntax error:

Traceback (most recent call last):
  File "yo.py", line 15, in <module>
    class C(B):
  File "/home/davidc/.envs/jaguar-dev/local/lib/python2.7/site-packages/attr/_make.py", line 194, in attributes
    return wrap(maybe_cl)
  File "/home/davidc/.envs/jaguar-dev/local/lib/python2.7/site-packages/attr/_make.py", line 186, in wrap
    cl = _add_init(cl)
  File "/home/davidc/.envs/jaguar-dev/local/lib/python2.7/site-packages/attr/_make.py", line 340, in _add_init
    bytecode = compile(script, unique_filename, "exec")
  File "<attrs generated init 24e3b3b777d1b457ffb869223ee4a4b7665529ed>", line 1
SyntaxError: duplicate argument 'a' in function definition

So it looks like one level of inheritance works (B works as expected), but not multiple.

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