-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
GH-139862: Remove color from HelpFormatter
#142274
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
GH-139862: Remove color from HelpFormatter
#142274
Conversation
Misc/NEWS.d/next/Library/2025-12-04-23-24-24.gh-issue-139862.NBfsD4.rst
Outdated
Show resolved
Hide resolved
|
(Updated from |
…BfsD4.rst Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
|
This PR broke instantiating the formatter outside the parser because import argparse
formatter = argparse.HelpFormatter(prog="program")
formatter.add_usage(usage=None, actions=[], groups=[])
print(formatter.format_help())This now raises an Traceback (most recent call last):
File "/tmp/t.py", line 5, in <module>
print(formatter.format_help())
~~~~~~~~~~~~~~~~~~~~~^^
File "/tmp/argparse.py", line 303, in format_help
help = self._root_section.format_help()
File "/tmp/argparse.py", line 228, in format_help
item_help = join([func(*args) for func, args in self.items])
~~~~^^^^^^^
File "/tmp/argparse.py", line 315, in _format_usage
t = self._theme
^^^^^^^^^^^
AttributeError: 'HelpFormatter' object has no attribute '_theme'This only broke a test over at https://github.com/hamdanal/rich-argparse and I am not sure if it a supported usage of the formatter. Let me know if I need to create an issue/PR. |
|
Hey @hamdanal, thanks for raising this! Direct instantiation of |
|
@hamdanal And thank you for testing the nightly and reporting so quickly :) |
After digging into this, I think that we should just remove color from being passed into HelpFormatter, since this never worked and was never documented. IMO, this should be controlled by the parser anyway.
argparseformatter handling ofcolor#139862