Re: [Python-Dev] descriptor __set_name__ and dataclasses

2018-03-27 Thread Nick Coghlan
On 27 March 2018 at 01:17, Eric V. Smith wrote: > On 3/26/18 11:10 AM, Eric V. Smith wrote: >> >> On 3/26/18 11:08 AM, Nick Coghlan wrote: >>> >>> On 27 March 2018 at 00:40, Eric V. Smith wrote: > > >>> Would it be feasible to define `Field.__set_name__`, and have that >>> call `default.__set_nam

Re: [Python-Dev] descriptor __set_name__ and dataclasses

2018-03-26 Thread Eric V. Smith
On 3/26/18 11:10 AM, Eric V. Smith wrote: On 3/26/18 11:08 AM, Nick Coghlan wrote: On 27 March 2018 at 00:40, Eric V. Smith wrote: Would it be feasible to define `Field.__set_name__`, and have that call `default.__set_name__` when the latter exists, and be a no-op otherwise? A clever idea!

Re: [Python-Dev] descriptor __set_name__ and dataclasses

2018-03-26 Thread Eric V. Smith
On 3/26/18 11:08 AM, Nick Coghlan wrote: On 27 March 2018 at 00:40, Eric V. Smith wrote: https://bugs.python.org/issue33141 points out an interesting issue with dataclasses and descriptors. Given this code: from dataclasses import * class D: """A descriptor class that knows its name."""

Re: [Python-Dev] descriptor __set_name__ and dataclasses

2018-03-26 Thread Nick Coghlan
On 27 March 2018 at 00:40, Eric V. Smith wrote: > https://bugs.python.org/issue33141 points out an interesting issue with > dataclasses and descriptors. > > Given this code: > > from dataclasses import * > > class D: > """A descriptor class that knows its name.""" > def __set_name__(self,