When I execute this script.
import inspect
from dataclasses import *
import enum
@dataclass
class SimpleDataObject(object):
field_a: int = field()
field_b: str = "asdad"
print([a[0] for a in inspect.getmembers(SimpleDataObject)])
I expected
['__annotations__', '__class__', '__dataclass_fields__', '__dataclass_params__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'field_a', 'field_b']
but got
['__annotations__', '__class__', '__dataclass_fields__', '__dataclass_params__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'field_b']
If this behavior is not intended, I propose a new patch with providing Inspect.isdataclass for Python 3.8 and Inspect._is_dataclss for Python 3.7
https://github.com/corona10/cpython/commit/c2665176ce836a7b328ddc09c6c7d3de0a2b29a0 |