Both pyright and mypy assume that __dataclass_fields__
exists on any dataclass-like construct:
from typing import dataclass_transform
@dataclass_transform()
class Model: pass
class Sub(Model):
pass
reveal_type(Sub.__dataclass_fields__) # dict[str, Any]
This is pretty minor so can be kept as is, but I feel like this is a false positive in the majority of cases (most libraries making use of @dataclass_transform
aren’t calling their structures with dataclass in the name, and usually don’t define this attribute either).
Should this be special cased and only applied to stdlib dataclasses? The spec says:
so I don’t have a strong opinion.