Re: [Python-Dev] PEP 544 (Protocols): adding a protocol to a class post-hoc

2018-07-01 Thread Ivan Levkivskyi
On 30 June 2018 at 23:54, Tin Tvrtković wrote: > [...] > > An attrs class has a special class-level field, __attrs_attrs__, which > holds the attribute definitions. So maybe we can define a protocol: > > class AttrsClass(Protocol): > __attrs_attrs__: ClassVar[Tuple[Attribute, ...]] > > then

[Python-Dev] PEP 544 (Protocols): adding a protocol to a class post-hoc

2018-06-30 Thread Tin Tvrtković
Hi, PEP 544 specifies this address as "Discussions-To" so I hope I'm at the right address. I think protocols as defined in the PEP are a very interesting idea and I'm thinking of ways of applying them. The first use case is in the context of attrs. attrs has a number of functions that work only