|
5 | 5 |
|
6 | 6 | from mypy.nodes import ( |
7 | 7 | ARG_OPT, ARG_NAMED, ARG_NAMED_OPT, ARG_POS, ARG_STAR, ARG_STAR2, MDEF, |
8 | | - Argument, AssignmentStmt, CallExpr, Context, Expression, JsonDict, |
| 8 | + Argument, AssignmentStmt, CallExpr, TypeAlias, Context, Expression, JsonDict, |
9 | 9 | NameExpr, RefExpr, SymbolTableNode, TempNode, TypeInfo, Var, TypeVarExpr, |
10 | 10 | PlaceholderNode |
11 | 11 | ) |
@@ -333,6 +333,20 @@ def collect_attributes(self) -> Optional[List[DataclassAttribute]]: |
333 | 333 |
|
334 | 334 | node = sym.node |
335 | 335 | assert not isinstance(node, PlaceholderNode) |
| 336 | + |
| 337 | + if isinstance(node, TypeAlias): |
| 338 | + ctx.api.fail( |
| 339 | + ( |
| 340 | + 'Type aliases inside dataclass definitions ' |
| 341 | + 'are not supported at runtime' |
| 342 | + ), |
| 343 | + node |
| 344 | + ) |
| 345 | + # Skip processing this node. This doesn't match the runtime behaviour, |
| 346 | + # but the only alternative would be to modify the SymbolTable, |
| 347 | + # and it's a little hairy to do that in a plugin. |
| 348 | + continue |
| 349 | + |
336 | 350 | assert isinstance(node, Var) |
337 | 351 |
|
338 | 352 | # x: ClassVar[int] is ignored by dataclasses. |
|
0 commit comments