GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — GH-139862: Remove `color` from HelpFormatter by savannahostrowski · Pull Request #142274 · python/cpython Conversation
|
|
(Updated from |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…BfsD4.rst Co-authored-by: Hugo van Kemenade <[email protected]>
There was an error while loading. Please reload this page.
Co-authored-by: Hugo van Kemenade <[email protected]>
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hey @hamdanal, thanks for raising this! Direct instantiation of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@hamdanal And thank you for testing the nightly and reporting so quickly :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This is broken with cpython main which removed the color keyword argument to HelperFormatter in python/cpython#142274
This is broken with cpython main which removed the color keyword argument to HelperFormatter in python/cpython#142274
This is broken with cpython main which removed the color keyword argument to HelperFormatter in python/cpython#142274
|
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 linux Type "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 linux Type "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 before pypa/build#962 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Reported as #142928, so it is trackable. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
agentgrep runs on Python 3.15, which becomes the default interpreter and the version CI tests. On 3.15 every command, `--version` included, failed with `TypeError: HelpFormatter.__init__() got an unexpected keyword argument 'color'`: the themed formatter forwarded `color=True` to `argparse.HelpFormatter`, and 3.15 removed that keyword (python/cpython#142274). The published release crashed the same way under a bare `uvx agentgrep`, which uv 0.13 runs on 3.15 (#168). - **Formatter fix**: the class `create_themed_formatter()` returns binds its theme as a class attribute instead of overriding `__init__`; argparse builds the formatter as `formatter_class(prog=...)` on 3.14 and 3.15 and applies color afterwards. - **Tests**: `tests/test_help_color.py` renders `--help` with color forced on and off; it fails on 3.15 without the fix. - **Python 3.15 default**: `.tool-versions` lists 3.15 first, the test matrix runs 3.15 in place of 3.14, and the release job builds on 3.15. - **Packaging**: the trove classifiers add Python 3.15, so PyPI lists it as supported. - **Dependabot**: override `katex` to `^0.18.2` in the docs pnpm workspace for GHSA-238p-pmpm-9mq7 until mermaid-cli 12 brings katex ^0.18; mermaid still renders flowcharts and `$$` labels. - **Changelog**: a Fixes entry, "agentgrep runs on Python 3.15". Fixes #168
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.