On Wed, 12 Jan 2022 at 00:12, Eric V. Smith <e...@trueblade.com> wrote: > > On 1/11/2022 3:44 PM, Brett Cannon wrote: > > > > >>> class C: 'foo' > ... > >>> C.__doc__ == 'foo' > True > > >>> class C: f'foo' > ... > >>> C.__doc__ == 'foo' > False > >>> C.__doc__ is None > True > > And there's a test to make sure constant f-strings are not doc strings: > https://github.com/python/cpython/blob/dce642f24418c58e67fa31a686575c980c31dd37/Lib/test/test_fstring.py#L406 >
Having something that looks like it sets the docstring, but silently doesn't is very surprising, though. Linters can warn about this, but linters are not a universal fix, and this is something that superficially looks entirely reasonable. -- Neil Muller drnlmul...@gmail.com _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/V3RS2Y2FGTIWLUMBAMJKRGHXUF4HUN2J/ Code of Conduct: http://python.org/psf/codeofconduct/