Description
In string.Formatter.{parse,get_field}
, we use simple #
comments to document methods. While it's picked up by pydoc (through inspect.getcomments()
), it's not picked up by IDEs. I suggest we cleanup those occurrences to improve code readability as well. I stumbled upon it by chance so there might be other places that need such cleanup.
Important
Only comments that are above a def
of a public function should be considered. Comments inside the function body or method body should be considered separately as it could also mean that the public API is incompletely documented on purpose (see #134082 (comment) and following).
- Report including private names: https://gist.github.com/picnixz/d4aa5ff5e82013966dc575f0709c4398#file-full-report-md
- Report for publicly-named API: https://gist.github.com/picnixz/d4aa5ff5e82013966dc575f0709c4398#file-report-md
Both reports parse private files as well as they can be re-exported to a public API. We still need to go through each occurrences to check if they are expected to be exposed or not (and thus the task is NOT an easy task for newcomers).
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Activity
string.Formatter
#134083picnixz commentedon May 16, 2025
I found a bunch of other occurrences, most of the time in old places such as
html.parser.HTMLParser.parse_starttag
:For internal interfaces, I'm fine leaving them as is, but for public ones, it might be better to use docstrings. It's also a chance to cleanup whitespaces when needed.
I've opened a PR as a PoC but I can close it if it's too much cosmetics (it's borderline cosmetics but there are some pros IMO). Thoughts @AA-Turner @hugovk @serhiy-storchaka?
StanFromIreland commentedon May 16, 2025
Are you looking for help, I can grep the docs later and provide a list of occourances.
picnixz commentedon May 16, 2025
Finding the occurrences isn't really hard. I want to first know whether this is a realistic and desirable feature.
hugovk commentedon May 16, 2025
picnixz commentedon May 16, 2025
Yes, that's how I found it :')
ryan-duve commentedon May 16, 2025
This would also be useful for IPython. In the vanilla Python interpreter I see:
but in IPython I only see:
21 remaining items