Skip to content

Commit

Permalink
[dataclass_transform] fix deserialization for frozen_default
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywright authored and JukkaL committed Apr 5, 2023
1 parent bfa9eac commit 7f2a5b5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
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
42 changes: 42 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,45 @@ builtins.pyi:12: note: "B" defined here
main:7: error: Unexpected keyword argument "y" for "B"
builtins.pyi:12: note: "B" defined here
==

[case frozenStays]
# 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]

[out]
==

0 comments on commit 7f2a5b5

Please sign in to comment.