Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multi-level inheritance #24

Closed
cournape opened this issue Aug 20, 2015 · 4 comments
Closed

Support for multi-level inheritance #24

cournape opened this issue Aug 20, 2015 · 4 comments

Comments

@cournape
Copy link
Contributor

@cournape cournape commented Aug 20, 2015

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.

@hynek
Copy link
Member

@hynek hynek commented Aug 20, 2015

Congratulations, you found the first bug in attrs. :)

@hynek hynek changed the title Support for inheritence ? Support for multiple inheritance Aug 20, 2015
@hynek hynek changed the title Support for multiple inheritance Support for multi-level inheritance Aug 20, 2015
@hynek hynek closed this in e245f3d Aug 20, 2015
@hynek
Copy link
Member

@hynek hynek commented Aug 20, 2015

If you could verify your issue is fixed I’d roll 15.1.0. Thanks!

@cournape
Copy link
Contributor Author

@cournape cournape commented Aug 20, 2015

Looks like it works ! Thanks for the prompt fix

@hynek
Copy link
Member

@hynek hynek commented Aug 20, 2015

(I have to correct myself: the first bug in a released version. the first bug overall was found by @econchick in #5, mea culpa ;))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.