File tree 1 file changed +14
-0
lines changed 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1566,6 +1566,20 @@ A(a=func).a()
1566
1566
A(a=func).a = func # E: Property "a" defined in "A" is read-only
1567
1567
[builtins fixtures/dataclasses.pyi]
1568
1568
1569
+ [case testDataclassInFunctionDoesNotCrash]
1570
+ # flags: --python-version 3.7
1571
+ from dataclasses import dataclass
1572
+
1573
+ def foo():
1574
+ @dataclass
1575
+ class Foo:
1576
+ foo: int
1577
+ # This used to crash (see #8703)
1578
+ # The return type of __call__ here needs to be something undefined
1579
+ # In order to trigger the crash that existed prior to #12762
1580
+ def __call__(self) -> asdf: ... # E: Name "asdf" is not defined
1581
+ [builtins fixtures/dataclasses.pyi]
1582
+
1569
1583
[case testDataclassesMultipleInheritanceWithNonDataclass]
1570
1584
# flags: --python-version 3.10
1571
1585
from dataclasses import dataclass
You can’t perform that action at this time.
0 commit comments