On Thu, 2021-12-09 at 12:32 +1100, Steven D'Aprano wrote:
> On Wed, Dec 08, 2021 at 09:45:35AM -0800, Paul Bryan wrote:
> 
> > I propose there is already a viable option in typing.Annotated.
> > Example: 
> > 
> > @dataclass
> > class InventoryItem:
> >     """Class for keeping track of an item in inventory."""
> >     
> >     name: Annotated[str, "Short name of the item."]
> >     unit_price: Annotated[float, "Price per unit in dollar."]
> >     ...
> 
> Oh nice! Guido's time machine strikes again.
> 
> So dataclasses could recognise Annotated and populate `__attrdoc__`.

Indeed.

> Should all classes do the same? How about top level module variables?

If we started with dataclass, it could be performed in the dataclass
decorator and make_dataclass functions. I think this would be low-
hanging fruit compared to classes and modules.


_______________________________________________
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/XWSFSHUYMTUVYGVTZLS2GFBEZVQQEZ4C/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to