Message 321706 - Python tracker

Message321706

Author corona10
Recipients corona10, eric.smith, serhiy.storchaka, yselivanov
Date 2018-07-16.04:12:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531714370.47.0.56676864532.issue34122@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2018-07-16 04:12:50corona10setrecipients: + corona10, eric.smith, serhiy.storchaka, yselivanov
2018-07-16 04:12:50corona10setmessageid: <1531714370.47.0.56676864532.issue34122@psf.upfronthosting.co.za>
2018-07-16 04:12:50corona10linkissue34122 messages
2018-07-16 04:12:49corona10create