On Wed, Jan 12, 2022 at 2:58 AM Neil Muller <[email protected]>
wrote:
> 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.
>
While f-strings in class scope could theoretically be valid docstrings a
lot of the time, the equivalent situation for function docstrings is much
less positive. A function like this the one below obviously problematic,
since the f-string value is not a compile-time constant:
def foo(x): f"is this a docstring? x is {x}"
I'm pretty sure f-strings cannot be used as docstrings in other contexts
because of how broken they'd be in functions.
--
Steven Barker
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/PQMAQIQR65OF3EDQYNWAHTWU44WKBE5A/
Code of Conduct: http://python.org/psf/codeofconduct/