dataclasses_frozen
error
Assignment to attribute of a frozen dataclass instance, or invalid frozen/non-frozen dataclass inheritance
@dataclass(frozen=True) instances are immutable — their attributes cannot be reassigned after construction. Additionally, a frozen dataclass cannot inherit from a non-frozen one, and vice versa.
@dataclass(frozen=True)
class Point:
x: float
p = Point(1.0)
p.x = 2.0 # E: dataclass is frozen
@dataclass # E: non-frozen cannot inherit from frozen
class Sub(Point):
pass
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
dataclasses_frozen down per-file or per-path from your editor or
pyproject.toml, or fix the code
so it type-checks. See the Type System rules and
the complete diagnostic reference.
Canonical URL: https://www.basilisk-python.dev/errors/dataclasses_frozen