Skip to content

bpo-42966: argparse: customizable help formatter #24377

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

monkeyman79
Copy link

@monkeyman79 monkeyman79 commented Jan 29, 2021

Added public CustomHelpFormat class and private _CustomizableHelpFormatter to provide accessible API for basic help format customizations.

This PR doesn't introduce any new formatting customization, just adds more accessible API for existing alternative help formatter classes and for changing basic HelpFormatter parameters (indentation), with possibility to extend it for future formatter classes.

https://bugs.python.org/issue42966

Added public class CustomHelpFormat and private
_CustomizableHelpFormatter to provide accessible API for basic help
format customizations.
Fixed minor mistakes in documentation
@monkeyman79 monkeyman79 changed the title bpo-42966: customizable help formatter bpo-42966: argparse: customizable help formatter Jan 29, 2021
@monkeyman79
Copy link
Author

Tests failed on macOS due to problems with ssl :( What now?

Lib/argparse.py Outdated
class CustomHelpFormat:
"""Customizable help formatter factory."""

def __init__(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not allow to pass the attributes by arguments ?

def __init__(self, *, 
             indent_increment: int = 2, 
             max_help_position: int = 24,
                    ...
):
        ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to avoid backward incompatiblity when list of attributes change. On the other hand, this can be solved by adding **kwargs at the end, so I think I'll try it this way.

Passing attributes to CustomHelpFormat constructor as keyword arguments
Fixed CustomHelpFormat constructor prototype in documentation
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Mar 11, 2021
Copy link
Contributor

@MaxwellDupre MaxwellDupre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran 1692 tests in 3.109s
OK
Looks ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants