I would like to add more support for this, because it could help annotate dataclasses in a natural manner, which is currently a weakness of Python type annotations, and which PEP 727 and PEP 747 don’t address either.
Something like this would allow annotations like
@dataclass
class MyClass
x = field(default_factory=list)
__init_type__ = list[str] | str
__attr_type__ = list[str]
__default__ = []
where currently the best annotation I can manage (for the purpose of PyLance) is x: list[str] | str = ...
. (Literally ...
because Pylance apparently can’t resolve the field
default.)