[issue33141] descriptor __set_name__ feature broken for dataclass descriptor fields

Eric V. Smith report at bugs.python.org
Mon Mar 26 06:28:57 EDT 2018


Eric V. Smith <eric at trueblade.com> added the comment:

That's a tough one. Because C.d is not set to a descriptor at type creation time (it's set to a Field object), the __set_name__ behavior is never invoked. It's when the @dataclass decorator is called that C.d is set to D().

https://docs.python.org/3/reference/datamodel.html#creating-the-class-object

I'm not sure it's possible to work around this without duplicating some of the type creation code, and even then I'm not convinced it's doable.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33141>
_______________________________________


More information about the Python-bugs-list mailing list