File tree 2 files changed +5
-10
lines changed 2 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -338,9 +338,9 @@ def collect_attributes(self) -> Optional[List[DataclassAttribute]]:
338
338
ctx .api .fail (
339
339
(
340
340
'Type aliases inside dataclass definitions '
341
- 'are not supported at runtime. '
341
+ 'are not supported at runtime'
342
342
),
343
- Context ( line = node . line , column = node . column )
343
+ node
344
344
)
345
345
# Now do our best to simulate the runtime,
346
346
# which treates a TypeAlias definition in a dataclass class
@@ -355,14 +355,9 @@ def collect_attributes(self) -> Optional[List[DataclassAttribute]]:
355
355
# Something else -- fallback to Any
356
356
else :
357
357
var_type = AnyType (TypeOfAny .from_error )
358
- var = Var (name = fullname , type = var_type )
358
+ var = Var (name = node . name , type = var_type )
359
359
var .info = cls .info
360
360
var ._fullname = fullname
361
- cls .info .names [fullname ] = SymbolTableNode (
362
- kind = MDEF ,
363
- node = var ,
364
- plugin_generated = True ,
365
- )
366
361
sym .node = node = var
367
362
368
363
assert isinstance (node , Var )
Original file line number Diff line number Diff line change @@ -525,7 +525,7 @@ class Foo:
525
525
526
526
@dataclass
527
527
class One:
528
- S: TypeAlias = Foo # E: Type aliases inside dataclass definitions are not supported at runtime.
528
+ S: TypeAlias = Foo # E: Type aliases inside dataclass definitions are not supported at runtime
529
529
530
530
a = One()
531
531
b = One(Foo)
@@ -537,7 +537,7 @@ reveal_type(b.S(98)) # N: Revealed type is "__main__.Foo"
537
537
538
538
@dataclass
539
539
class Two:
540
- S: TypeAlias = Callable[[int], str] # E: Type aliases inside dataclass definitions are not supported at runtime.
540
+ S: TypeAlias = Callable[[int], str] # E: Type aliases inside dataclass definitions are not supported at runtime
541
541
542
542
c = Two()
543
543
reveal_type(c.S) # N: Revealed type is "Any"
You can’t perform that action at this time.
0 commit comments