diff --git a/mypy/nodes.py b/mypy/nodes.py index 72a23d4f07894..d5ce8d6751272 100644 --- a/mypy/nodes.py +++ b/mypy/nodes.py @@ -3915,7 +3915,7 @@ def serialize(self) -> JsonDict: "eq_default": self.eq_default, "order_default": self.order_default, "kw_only_default": self.kw_only_default, - "frozen_only_default": self.frozen_default, + "frozen_default": self.frozen_default, "field_specifiers": list(self.field_specifiers), } diff --git a/test-data/unit/fine-grained-dataclass-transform.test b/test-data/unit/fine-grained-dataclass-transform.test index 7dc852f1d733c..6d37ecaf74f88 100644 --- a/test-data/unit/fine-grained-dataclass-transform.test +++ b/test-data/unit/fine-grained-dataclass-transform.test @@ -90,3 +90,52 @@ builtins.pyi:12: note: "B" defined here main:7: error: Unexpected keyword argument "y" for "B" builtins.pyi:12: note: "B" defined here == + +[case frozenInheritanceViaDefault] +# flags: --python-version 3.11 +from foo import Foo + +foo = Foo(base=0, foo=1) + +[file transform.py] +from typing import dataclass_transform, Type + +@dataclass_transform(frozen_default=True) +def dataclass(cls: Type) -> Type: return cls + +[file base.py] +from transform import dataclass + +@dataclass +class Base: + base: int + +[file foo.py] +from base import Base +from transform import dataclass + +@dataclass +class Foo(Base): + foo: int + +[file foo.py.2] +from base import Base +from transform import dataclass + +@dataclass +class Foo(Base): + foo: int + bar: int = 0 + +[typing fixtures/typing-full.pyi] +[builtins fixtures/dataclasses.pyi] + +# If the frozen parameter is being maintained correctly, we *don't* expect to see issues; if it's +# broken in incremental mode, then we'll see an error about inheriting a non-frozen class from a +# frozen one. +# +# Ideally we'd also add a `foo.foo = 2` to confirm that frozen semantics are actually being +# enforced, but incremental tests currently can't start with an error, which makes it tricky to +# write such a test case. +[out] +==