Author Ricyteach
Recipients Ricyteach, eric.smith
Date 2018-03-26.13:49:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAP0nE65aF-1-WubbFEHcHuKmVu40Xi_uoU3V0MdcYGhC45dRcQ@mail.gmail.com>
In-reply-to <1522061251.25.0.467229070634.issue33141@psf.upfronthosting.co.za>
Content
hmmm... if I check the C.d class attribute it seems to return the
descriptor instance object (not a field object) before any C instances have
been created. i guess this is just a part of how the dataclass
implementation works.

i didn't realize there's nothing "special" going on with descriptors here-
the descriptors "just work" by virtue of being set to the class attribute
at creation time. interesting.

maybe because of this descriptors should short-circuit the field creation
process entirely? that would be a shame though. having the option of
auto-including a descriptor in the class repr turns out to be very useful
and i'm already playing around with it in a project.

one idea: what if it there were a keyword argument to mark a field as a
descriptor, allowing tje descriptor to be set at type creation? this would
need to disallow init=True, i think. and setting a field default to a
descriptor class would then raise a type error.

---
Ricky.

"I've never met a Kentucky man who wasn't either thinking about going home
or actually going home." - Happy Chandler

On Mon, Mar 26, 2018 at 6:47 AM, Eric V. Smith <report@bugs.python.org>
wrote:

>
> Eric V. Smith <eric@trueblade.com> added the comment:
>
> I suppose I could, when overwriting the class member, check for
> inspect.ismethoddescriptor and call __set_name__ myself.
>
> ----------
> components: +Library (Lib)
> versions: +Python 3.8
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue33141>
> _______________________________________
>
History
Date User Action Args
2018-03-26 13:49:01Ricyteachsetrecipients: + Ricyteach, eric.smith
2018-03-26 13:49:01Ricyteachlinkissue33141 messages
2018-03-26 13:49:01Ricyteachcreate