Skip to content

Misaligned columns in help('topics') due to the length of "ASSIGNMENTEXPRESSIONS" #125225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
EtiennePelletier opened this issue Oct 9, 2024 · 1 comment
Labels
docs Documentation in the Doc dir

Comments

@EtiennePelletier
Copy link
Contributor

EtiennePelletier commented Oct 9, 2024

Documentation

Description

The pydoc.Helper.list function currently uses default values of 80 characters per line and 4 columns. This provides an implicit maximum length of 19 characters per item to ensure columns are aligned properly (the item length is not verified within the function).

Historically, the longest values were _testimportmultiple from help('module') and AUGMENTEDASSIGNMENT from help('topics'), both with a length of 19 characters.

The recent addition of "ASSIGNMENTEXPRESSIONS" (21 characters) in PR 124641 causes misaligned columns with these default values. As seen in Python 3.13.0:

>>> help('topics')

Here is a list of available topics.  Enter any topic name to get more help.

ASSERTION           DEBUGGING           LITERALS            SEQUENCES
ASSIGNMENT          DELETION            LOOPING             SHIFTING
ASSIGNMENTEXPRESSIONS DICTIONARIES        MAPPINGMETHODS      SLICINGS
ATTRIBUTEMETHODS    DICTIONARYLITERALS  MAPPINGS            SPECIALATTRIBUTES
ATTRIBUTES          DYNAMICFEATURES     METHODS             SPECIALIDENTIFIERS
...

Impact

This misalignment affects the readability of the output, making it a bit more difficult to quickly scan through it.

Proposed Solutions

I see two simple options to address this issue, but I’m open to any other suggestions as well:

  1. Increase the line width to 88 characters:
    To preserve the default four columns, a minimum width of 88 characters would be required to ensure each item, including "ASSIGNMENTEXPRESSIONS", fits within its column:

    ASSERTION             DEBUGGING             LITERALS              SEQUENCES
    ASSIGNMENT            DELETION              LOOPING               SHIFTING
    ASSIGNMENTEXPRESSIONS DICTIONARIES          MAPPINGMETHODS        SLICINGS
    ATTRIBUTEMETHODS      DICTIONARYLITERALS    MAPPINGS              SPECIALATTRIBUTES
    ATTRIBUTES            DYNAMICFEATURES       METHODS               SPECIALIDENTIFIERS
    ...
    
  2. Reduce the number of columns to 3 (Recommendation):
    Reducing the column count to 3 when listing topics would provide enough space for longer topic names (up to 25 characters). This solution is preferred for compatibility with many terminals that default to 80 characters per line:

    ASSERTION                 EXCEPTIONS                PACKAGES
    ASSIGNMENT                EXECUTION                 POWER
    ASSIGNMENTEXPRESSIONS     EXPRESSIONS               PRECEDENCE
    ATTRIBUTEMETHODS          FLOAT                     PRIVATENAMES
    ATTRIBUTES                FORMATTING                RETURNING
    ...
    

🙂

Linked PRs

@EtiennePelletier EtiennePelletier added the docs Documentation in the Doc dir label Oct 9, 2024
@zware
Copy link
Member

zware commented Oct 9, 2024

I'm in favor of your option 2. Are you interested in submitting a pull request?

ambv added a commit that referenced this issue May 19, 2025
The 'help("topics")' output was misaligned due to "ASSIGNMENTEXPRESSIONS"
exceeding the implicit maximum default column width of 19 characters.

Reduced the number of columns from 4 to 3 in the listtopics()
function to allow more space for longer topic names.

Co-authored-by: Łukasz Langa <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 19, 2025
…thongh-125226)

The 'help("topics")' output was misaligned due to "ASSIGNMENTEXPRESSIONS"
exceeding the implicit maximum default column width of 19 characters.

Reduced the number of columns from 4 to 3 in the listtopics()
function to allow more space for longer topic names.
(cherry picked from commit b22460c)

Co-authored-by: Étienne Pelletier <[email protected]>
Co-authored-by: Łukasz Langa <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 19, 2025
…thongh-125226)

The 'help("topics")' output was misaligned due to "ASSIGNMENTEXPRESSIONS"
exceeding the implicit maximum default column width of 19 characters.

Reduced the number of columns from 4 to 3 in the listtopics()
function to allow more space for longer topic names.
(cherry picked from commit b22460c)

Co-authored-by: Étienne Pelletier <[email protected]>
Co-authored-by: Łukasz Langa <[email protected]>
ambv added a commit that referenced this issue May 19, 2025
…h-125226) (gh-134225)

The 'help("topics")' output was misaligned due to "ASSIGNMENTEXPRESSIONS"
exceeding the implicit maximum default column width of 19 characters.

Reduced the number of columns from 4 to 3 in the listtopics()
function to allow more space for longer topic names.
(cherry picked from commit b22460c)

Co-authored-by: Étienne Pelletier <[email protected]>
Co-authored-by: Łukasz Langa <[email protected]>
ambv added a commit that referenced this issue May 19, 2025
…h-125226) (#134226)

The 'help("topics")' output was misaligned due to "ASSIGNMENTEXPRESSIONS"
exceeding the implicit maximum default column width of 19 characters.

Reduced the number of columns from 4 to 3 in the listtopics()
function to allow more space for longer topic names.
(cherry picked from commit b22460c)

Co-authored-by: Étienne Pelletier <[email protected]>
Co-authored-by: Łukasz Langa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
Status: Todo
Development

No branches or pull requests

2 participants