Skip to content

attrs classes which inherit from slotted non-attrs classes do not inherit their bases' slots #1222

@glyph

Description

@glyph

This seems straightforwardly incorrect to me:

class NoAttrsSlotsBase:
    __slots__ = ['base']

class NoAttrsSlotsChild(NoAttrsSlotsBase):
    __slots__ = ['child']

from attrs import define

@define()
class AttrsWithNoAttrsBase:
    attrs_child: str = "default"

print(NoAttrsSlotsChild.base)
print(AttrsWithNoAttrsBase.base)
<member 'base' of 'NoAttrsSlotsBase' objects>
Traceback (most recent call last):
  File "slots2.py", line 16, in <module>
    print(AttrsWithNoAttrsBase.base)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'AttrsWithNoAttrsBase' has no attribute 'base'

Should it be fixed?

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