python / python/cpython

Argument Clinic does not check the length of parameter descriptions

Open
#155,228 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.16 topic-argument-clinic type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

The docstring line length check is performed before the parameter descriptions are added to the docstring:

        max_width = f.docstring_line_width
        summary_len = len(lines[0])
        max_body = max(map(len, lines[1:]))
        ...
        if not parameters_marker_count:
            lines.insert(2, '{parameters}')

So a description of any length is accepted without a warning.

24 functions in the current tree have parameter description lines longer than the limit (the number of too long lines is in parentheses):

  • _lzma.LZMADecompressor (4)
  • select.epoll (3)
  • int.to_bytes (2)
  • select.kqueue.control (2)
  • str.encode (2)
  • winreg.SetValueEx (2)
  • _sqlite3.Connection.getconfig
  • _sqlite3.Connection.setconfig
  • _sre.template
  • _winapi.RegisterEventSource
  • _zstd.ZstdCompressor.set_pledged_input_size
  • bytearray.decode
  • bytearray.rsplit
  • bytearray.split
  • bytearray.take_bytes
  • bytes.decode
  • bytes.rsplit
  • bytes.split
  • gc.set_debug
  • os.timerfd_create
  • select.poll.poll
  • winreg.ConnectRegistry
  • winreg.DeleteTree
  • zlib._ZlibDecompressor

This is easy to miss for a cloned function, which inherits the descriptions of the function it clones: bytes.split and bytes.rsplit (and the bytearray pair) both have a 69 character line, and rewrapping the description in bytes.split does not make Argument Clinic report anything for either of them.

This is a leftover of #150285.

Linked PRs
  • gh-155251

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Argument Clinic docstring line-length check shown in the issue and review the context from #150285. Use the listed affected functions, including cloned pairs such as bytes.split and bytes.rsplit, to verify that overly long parameter descriptions are detected and that the linked PR gh-155251 reflects the completed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.