Check if a class is a dataclass in Python
Docs import dataclasses dataclasses.is_dataclass(something) As mentioned by @Arne internally it simply checks hasattr(something, ‘__dataclass_fields__’), but I’d recommend to not rely on this attribute and directly use is_dataclass. Why you should not rely on __dataclass_fields__: This attribute is not a public API: it’s not mentioned anywhere in the docs. It’s an implementation detail, and so it’s … Read more