File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 23
23
ClassDef ,
24
24
Context ,
25
25
DataclassTransformSpec ,
26
+ Decorator ,
26
27
Expression ,
27
28
FuncDef ,
28
29
FuncItem ,
@@ -575,6 +576,10 @@ def collect_attributes(self) -> list[DataclassAttribute] | None:
575
576
# but the only alternative would be to modify the SymbolTable,
576
577
# and it's a little hairy to do that in a plugin.
577
578
continue
579
+ if isinstance (node , Decorator ):
580
+ # This might be a property / field name clash.
581
+ # We will issue an error later.
582
+ continue
578
583
579
584
assert isinstance (node , Var )
580
585
Original file line number Diff line number Diff line change @@ -2519,3 +2519,15 @@ a: MyDataclass
2519
2519
b = [a, a] # trigger joining the types
2520
2520
2521
2521
[builtins fixtures/dataclasses.pyi]
2522
+
2523
+ [case testPropertyAndFieldRedefinitionNoCrash]
2524
+ from dataclasses import dataclass
2525
+
2526
+ @dataclass
2527
+ class Foo:
2528
+ @property
2529
+ def c(self) -> int:
2530
+ return 0
2531
+
2532
+ c: int # E: Name "c" already defined on line 5
2533
+ [builtins fixtures/dataclasses.pyi]
You can’t perform that action at this time.
0 commit comments