I think that because Sphinx could interpret strings below attributes for documentation, that perhaps we should go in that direction in Python proper.
Personally, I find this more readable: class C: x: Annotated[str, "Doc string"] y: Annotated[int, "Doc string"] over: class C: x: str "Doc string" y: int "Doc string" On Sun, 2021-12-12 at 10:00 +1100, Steven D'Aprano wrote: > On Sat, Dec 11, 2021 at 10:07:50AM -0800, Christopher Barker wrote: > > > Where/how should class attribute doc strings be stored? > > > > Tacked on to the class __doc__ ? > > Another dict? > > __attr_doc__ > > Added to __annotaions__ ? > > Something else? > > Didn't we decide there was an existing feature for this, no need for > new syntax? > > > > > from typing import Annotated > > > > class C: > ... x: Annotated[int, "Doc string"] = 123 > ... > > > > C.x > 123 > > > > C.__annotations__ > {'x': typing.Annotated[int, 'Doc string']} > > _______________________________________________ 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/MEFYE3FPMI7L4QPO4PRJ424IJ3HPXFEN/ Code of Conduct: http://python.org/psf/codeofconduct/