Skip to content

Commit 7f2a5b5

Browse files
wesleywrightJukkaL
authored andcommitted
[dataclass_transform] fix deserialization for frozen_default
1 parent bfa9eac commit 7f2a5b5

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

‎mypy/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3915,7 +3915,7 @@ def serialize(self) -> JsonDict:
39153915
"eq_default": self.eq_default,
39163916
"order_default": self.order_default,
39173917
"kw_only_default": self.kw_only_default,
3918-
"frozen_only_default": self.frozen_default,
3918+
"frozen_default": self.frozen_default,
39193919
"field_specifiers": list(self.field_specifiers),
39203920
}
39213921

‎test-data/unit/fine-grained-dataclass-transform.test

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,45 @@ builtins.pyi:12: note: "B" defined here
9090
main:7: error: Unexpected keyword argument "y" for "B"
9191
builtins.pyi:12: note: "B" defined here
9292
==
93+
94+
[case frozenStays]
95+
# flags: --python-version 3.11
96+
from foo import Foo
97+
98+
foo = Foo(base=0, foo=1)
99+
100+
[file transform.py]
101+
from typing import dataclass_transform, Type
102+
103+
@dataclass_transform(frozen_default=True)
104+
def dataclass(cls: Type) -> Type: return cls
105+
106+
[file base.py]
107+
from transform import dataclass
108+
109+
@dataclass
110+
class Base:
111+
base: int
112+
113+
[file foo.py]
114+
from base import Base
115+
from transform import dataclass
116+
117+
@dataclass
118+
class Foo(Base):
119+
foo: int
120+
121+
[file foo.py.2]
122+
from base import Base
123+
from transform import dataclass
124+
125+
@dataclass
126+
class Foo(Base):
127+
foo: int
128+
bar: int = 0
129+
130+
[typing fixtures/typing-full.pyi]
131+
[builtins fixtures/dataclasses.pyi]
132+
133+
[out]
134+
==

0 commit comments

Comments
 (0)