Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
GH-139862: Removecolor 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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
GH-139862: Removecolor from HelpFormatter#142274
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Misc/NEWS.d/next/Library/2025-12-04-23-24-24.gh-issue-139862.NBfsD4.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
hugovk commentedDec 5, 2025
(Updated from |
…BfsD4.rstCo-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
4b14529 intopython:mainUh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
hamdanal commentedDec 7, 2025
This PR broke instantiating the formatter outside the parser because importargparseformatter=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", line5, in<module>print(formatter.format_help())~~~~~~~~~~~~~~~~~~~~~^^ File"/tmp/argparse.py", line303, informat_helphelp=self._root_section.format_help() File"/tmp/argparse.py", line228, informat_help item_help= join([func(*args)for func, argsinself.items])~~~~^^^^^^^ File"/tmp/argparse.py", line315, in_format_usage t=self._theme^^^^^^^^^^^AttributeError:'HelpFormatter' object has no attribute '_theme' This only broke a test over athttps://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. |
savannahostrowski commentedDec 7, 2025
hugovk commentedDec 7, 2025
@hamdanal And thank you for testing the nightly and reporting so quickly :) |
This is broken with cpython main which removed the color keyword argumentto HelperFormatter inpython/cpython#142274
This is broken with cpython main which removed the color keyword argumentto HelperFormatter inpython/cpython#142274
This is broken with cpython main which removed the color keyword argumentto HelperFormatter inpython/cpython#142274
hroncok commentedDec 18, 2025
Beware, this also breaks existing code that sets the color this way. This was possible in 3.14 and now it explodes: Python 3.14.2 (main, Dec 5 2025, 00:00:00) [GCC 15.2.1 20251111 (Red Hat 15.2.1-4)] on linuxType "help", "copyright", "credits" or "license" for more information.>>>import argparse>>> argparse.HelpFormatter(prog='',color=True)<argparse.HelpFormatter object at 0x7fd998cd1400> Python 3.15.0a3 (main, Dec 16 2025, 00:00:00) [GCC 15.2.1 20251211 (Red Hat 15.2.1-5)] on linuxType "help", "copyright", "credits" or "license" for more information.>>>import argparse>>> argparse.HelpFormatter(prog='',color=True)Traceback (most recent call last): File "<python-input-1>", line 1, in <module> argparse.HelpFormatter(prog='', color=True) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^TypeError: HelpFormatter.__init__() got an unexpected keyword argument 'color' In particular, this breaks pypa/build beforepypa/build#962 |
hroncok commentedDec 18, 2025
Reported as#142928, so it is trackable. |
Uh oh!
There was an error while loading.Please reload this page.
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