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

Exception when using auto_attribs and a attribute named property #429

Closed
dstufft opened this issue Aug 21, 2018 · 1 comment
Closed

Exception when using auto_attribs and a attribute named property #429

dstufft opened this issue Aug 21, 2018 · 1 comment
Milestone

Comments

@dstufft
Copy link
Member

dstufft commented Aug 21, 2018

Given a class like:

@attr.s(auto_attribs=True)
class Foo:

    property: str
    other: str

Attrs is raising an exception:

Traceback (most recent call last):
  File "f.py", line 13, in <module>
    @attr.s(auto_attribs=True)
  File "/usr/local/lib/python3.6/site-packages/attr/_make.py", line 729, in wrap
    builder = _ClassBuilder(cls, these, slots, frozen, auto_attribs)
  File "/usr/local/lib/python3.6/site-packages/attr/_make.py", line 409, in __init__
    cls, these, auto_attribs
  File "/usr/local/lib/python3.6/site-packages/attr/_make.py", line 354, in _transform_attrs
    AttrsClass = _make_attr_tuple_class(cls.__name__, attr_names)
  File "/usr/local/lib/python3.6/site-packages/attr/_make.py", line 220, in _make_attr_tuple_class
    eval(compile("\n".join(attr_class_template), "", "exec"), globs)
  File "", line 1, in <module>
  File "", line 4, in BreaksAttributes
TypeError: 'property' object is not callable

What's odd here, is that it works fine as long as property is the last item in the class, e.g.:

@attr.s(auto_attribs=True)
class Foo:

    other: str
    property: str

this works fine and doesn't raise an error.

@dstufft
Copy link
Member Author

dstufft commented Aug 21, 2018

Upon further investigation, this doesn't appear to have anything to do with the auto_attribs=True, as it also fails without that, using attr.ib().

@hynek hynek added this to the 18.2 milestone Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants