File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
crates/ty_python_semantic/resources/mdtest/dataclasses Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -110,14 +110,22 @@ reveal_type(D.__init__) # revealed: (self: D, x: int) -> None
110110```
111111
112112If attributes without default values are declared after attributes with default values, a
113- ` TypeError ` will be raised at runtime. Ideally, we would emit a diagnostic in that case:
113+ ` TypeError ` will be raised at runtime. We emit a diagnostic in that case:
114114
115115``` py
116+ from dataclasses import field
117+
116118@dataclass
117119class D :
118120 x: int = 1
119121 # error: [dataclass-field-order] "Required field `y` cannot be defined after fields with default values"
120122 y: str
123+
124+ @dataclass
125+ class E :
126+ x: int = field(default = 3 )
127+ # error: [dataclass-field-order]
128+ y: str
121129```
122130
123131Pure class attributes (` ClassVar ` ) are not included in the signature of ` __init__ ` :
You can’t perform that action at this time.
0 commit comments