Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down
49 changes: 49 additions & 0 deletions test-data/unit/fine-grained-dataclass-transform.test
Original file line number Diff line number Diff line change
Expand Up @@ -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]
==