使用 `type[...]` 参数调用 `dataclass_transform` 函数时,返回的不是声明的返回类型,而是内部占位符类型
info[revealed-type]: Revealed type
--> repro.py:15:13
|
15 | reveal_type(Decorated) # <class 'Decorated'>: correct
| ^^^^^^^^^^^^^ <class 'Decorated'>
info[revealed-type]: Revealed type
--> repro.py:16:13
|
16 | reveal_type(Decorated(1)) # Decorated: correct
| ^^^^^^^^^^^^ Decorated
info[revealed-type]: Revealed type
--> repro.py:24:17
|
24 | reveal_type(record(Point)) # <class 'Point'>: correct
| ^^^^^^^^^^^^^ <class 'Point'>
info[revealed-type]: Revealed type
--> repro.py:28:17
|
28 | reveal_type(record(cls)) # placeholder; expected type[Point]
| ^^^^^^^^^^^ <decorator produced by dataclass-like function>
info[revealed-type]: Revealed type --> repro.py:33:17 | 33 | reveal_type(built) # …
内容来源: astral-sh/ty