If you're proposing something like this, then I think it would be compatible:
class Hmm: # this: int that: float # pos: PosOnly # these: str those: str # key: KWOnly # some: list On Thu, 2021-03-11 at 14:06 -0800, Ethan Furman wrote: > On 3/11/21 10:50 AM, Paul Bryan wrote: > > On Thu, 2021-03-11 at 10:45 -0800, Ethan Furman wrote: > > > On 3/10/21 9:47 PM, Eric V. Smith wrote: > > > > > > > I'm not sure of the best way to achieve this. Using flags to > > > > field() > > > > doesn't sound awesome, but could be made to work. Or maybe > > > > special > > > > field names or types? I'm not crazy about that, but using > > > > special > > > > types would let you do something like: > > > > > > > > @dataclasses.dataclass > > > > class Point: > > > > x: int = 0 > > > > _: dataclasses.KEYWORD_ONLY > > > > y: int > > > > z: int > > > > t: int = 0 > > > > > > Maybe something like this? > > > > > > class Hmm: > > > # > > > this: int > > > that: float > > > # > > > pos: '/' > > > # > > > these: str > > > those: str > > > # > > > key: '*' > > > # > > > some: list > > > > > > >>> Hmm.__dict__['__annotations__'] > > > { > > > 'this': <class 'int'>, > > > 'that': <class 'float'>, > > > 'pos': '/', > > > 'these': <class 'str'>, > > > 'those': <class 'str'>, > > > 'key': '*', > > > 'some': <class 'list'>, > > > } > > > > > > The name of 'pos' and 'key' can be convention, since the actual > > > name > > > is irrelevant. They do have to be unique, though. ;-) > > > > It's current convention (and is used by typing module and static > > type > > checkers) that string annotations evaluate to valid Python types. > > So make '/' and '*' be imports from dataclasses: > > from dataclasses import dataclass, PosOnly, KWOnly > > -- > ~Ethan~ > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/6L4W5OB23FBWZ7EZYDNCYSGT2CUAKYSX/ > Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/VPSE34Z35XOXGFJMGTMLWDAMF7JKJYOJ/ Code of Conduct: http://python.org/psf/codeofconduct/