New submission from Dong-hee Na <donghee.n...@gmail.com>:
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 ---------- components: Library (Lib) files: inspect_dataclass.py messages: 321706 nosy: corona10, eric.smith, serhiy.storchaka, yselivanov priority: normal severity: normal status: open title: inspect.getmembers does not retrive dataclass's __dataclass_fields__ properly versions: Python 3.7, Python 3.8 Added file: https://bugs.python.org/file47693/inspect_dataclass.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34122> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com