Skip to content

Subclasses don't inherit readonly option #15

@hulsed

Description

@hulsed

For example,

class ImmutableParameter(dataobject, readonly=True):
    b: float = 1.0
    def example_method(self):
        return 20

class ImmutableSubclass(ImmutableParameter):
    a: float = 2.0

I would expect (or like to have a way) for 'a' to be an immutable field without setting readonly=True as an option in the subclass. Instead, the following is possible:

ims = ImmutableSubclass()
ims.a = 3.0

I will note that the behavior for inherited fields is correct, returning the expected AttributeError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions