Python class attributes marked read-only when inheriting from dataclass in IntelliJ

33 Views Asked by At

I have a regular class inheriting from a frozen dataclass.

The attributes in my regular class are marked as 'read-only'. Which I understand due to inheriting the characteristics of the frozen dataclass.

However in IntelliJ these attributes are marked with a red line stating "Invalid definition and usage of Data Classes options"

The attributes are still available, and I'm not looking to change them. Is this an IntelliJ thing, throwing up an Inspection which isn't valid? Or am I not understanding inheritance from a dataclass correctly?

Examples:

@dataclass(frozen=True)
class Page1(ABC):

    something1: thing1
    something2: thing2
class Page2(Page1):

    def __init__(self, page: BasePage):
        super().__init__(something1=page.thing1,
                         something2=page.thing2)
        self.attr1: str = 'some_string'
        self.attr2 = "Hello"
        self.attr3 = "Goodbye"

self.attr1, 2 and 3 look like the following:

enter image description here

enter image description here

Any help would be great, thanks!

0

There are 0 best solutions below