[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-18 Thread Jim J. Jewett
Guido van Rossum wrote: > I personally think F-strings should not be usable as docstrings. If you > want a dynamically calculated docstring you should assign it dynamically, > not smuggle it in using a string-like expression. We don't allow "blah {x} > blah".format(x=1) as a docstring either, not

[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-13 Thread Steve Holden
On Tue, Jan 11, 2022 at 6:24 PM Guido van Rossum wrote: > I personally think F-strings should not be usable as docstrings. If you > want a dynamically calculated docstring you should assign it dynamically, > not smuggle it in using a string-like expression. We don't allow "blah {x} >

[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-12 Thread Neil Muller
On Thu, 13 Jan 2022 at 02:31, Steven Barker wrote: > > 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 >

[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-12 Thread Steven Barker
On Wed, Jan 12, 2022 at 2:58 AM Neil Muller 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

[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-12 Thread Neil Muller
On Wed, 12 Jan 2022 at 00:12, Eric V. Smith 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

[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-11 Thread Eric V. Smith
On 1/11/2022 3:44 PM, Brett Cannon wrote: On Tue, Jan 11, 2022 at 10:40 AM Gregory P. Smith wrote: On Tue, Jan 11, 2022 at 10:29 AM Guido van Rossum wrote: I personally think F-strings should not be usable as docstrings. If you want a dynamically calculated

[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-11 Thread Brett Cannon
On Tue, Jan 11, 2022 at 10:40 AM Gregory P. Smith wrote: > > On Tue, Jan 11, 2022 at 10:29 AM Guido van Rossum > wrote: > >> I personally think F-strings should not be usable as docstrings. If you >> want a dynamically calculated docstring you should assign it dynamically, >> not smuggle it in

[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-11 Thread Gregory P. Smith
On Tue, Jan 11, 2022 at 10:29 AM Guido van Rossum wrote: > I personally think F-strings should not be usable as docstrings. If you > want a dynamically calculated docstring you should assign it dynamically, > not smuggle it in using a string-like expression. We don't allow "blah {x} >

[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-11 Thread Guido van Rossum
I personally think F-strings should not be usable as docstrings. If you want a dynamically calculated docstring you should assign it dynamically, not smuggle it in using a string-like expression. We don't allow "blah {x} blah".format(x=1) as a docstring either, not "foo %s bar" % x. On Tue, Jan

[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-11 Thread Antoine Pitrou
On Tue, 11 Jan 2022 10:58:03 -0500 "Eric V. Smith" wrote: > Constant f-strings (those without substitutions) as doc strings used to > work, since the compiler turns them into normal strings. > > I can't find exactly where it was removed, but there was definitely > discussion about it. See

[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022-01-11 Thread Eric V. Smith
Constant f-strings (those without substitutions) as doc strings used to work, since the compiler turns them into normal strings. I can't find exactly where it was removed, but there was definitely discussion about it. See https://bugs.python.org/issue28739 for at least part of the discussion.