|
1 | 1 | """Plugin that provides support for dataclasses."""
|
2 | 2 |
|
3 |
| -from typing import Dict, List, Set, Tuple, Optional, Union |
| 3 | +from typing import Dict, List, Set, Tuple, Optional |
4 | 4 | from typing_extensions import Final
|
5 | 5 |
|
6 | 6 | from mypy.nodes import (
|
|
16 | 16 | from mypy.typeops import map_type_from_supertype
|
17 | 17 | from mypy.types import (
|
18 | 18 | Type, Instance, NoneType, TypeVarType, CallableType, TupleType, LiteralType,
|
19 |
| - get_proper_type, AnyType, TypeOfAny, TypeType, |
| 19 | + get_proper_type, AnyType, TypeOfAny, |
20 | 20 | )
|
21 | 21 | from mypy.server.trigger import make_wildcard_trigger
|
22 | 22 | from mypy.state import state
|
@@ -342,23 +342,10 @@ def collect_attributes(self) -> Optional[List[DataclassAttribute]]:
|
342 | 342 | ),
|
343 | 343 | node
|
344 | 344 | )
|
345 |
| - # Now do our best to simulate the runtime, |
346 |
| - # which treates a TypeAlias definition in a dataclass class |
347 |
| - # as an instance field with a default value. |
348 |
| - # |
349 |
| - # Replace the `TypeAlias` node with a `Var` node, so that we do the same. |
350 |
| - target, fullname = node.target, node.fullname |
351 |
| - proper_target = get_proper_type(target) |
352 |
| - var_type: Union[TypeType, AnyType] |
353 |
| - if isinstance(proper_target, Instance): |
354 |
| - var_type = TypeType(proper_target, line=node.line, column=node.column) |
355 |
| - # Something else -- fallback to Any |
356 |
| - else: |
357 |
| - var_type = AnyType(TypeOfAny.from_error) |
358 |
| - var = Var(name=node.name, type=var_type) |
359 |
| - var.info = cls.info |
360 |
| - var._fullname = fullname |
361 |
| - sym.node = node = var |
| 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 |
362 | 349 |
|
363 | 350 | assert isinstance(node, Var)
|
364 | 351 |
|
|
0 commit comments