Skip to content

Python 3.14: TypeError: HelpFormatter.__init__() got an unexpected keyword argument 'prefix_chars' #3523

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
The-Compiler opened this issue May 8, 2025 · 1 comment · May be fixed by #3524

Comments

@The-Compiler
Copy link
Member

Issue

With Python 3.14.0b1, tox immediately fails to start with TypeError: HelpFormatter.__init__() got an unexpected keyword argument 'prefix_chars', because it overrides HelpFormatter in an incompatible way.

This is due to:

See also:

Environment

Provide at least:

  • OS: Archlinux, Python 3.14.0b1
Output of pip list of the host Python, where tox is installed
cachetools    5.5.2
chardet       5.2.0
colorama      0.4.6
distlib       0.3.9
filelock      3.18.0
packaging     25.0
pip           25.1.1
platformdirs  4.3.8
pluggy        1.5.0
pyproject-api 1.9.0
tox           4.25.1.dev6+g4a8e50e2 /home/florian/tmp/tox
virtualenv    20.31.1

Output of running tox

Output of tox -rvv
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/florian/tmp/tox/src/tox/__main__.py", line 6, in <module>
    run()
    ~~~^^
  File "/home/florian/tmp/tox/src/tox/run.py", line 20, in run
    result = main(sys.argv[1:] if args is None else args)
  File "/home/florian/tmp/tox/src/tox/run.py", line 39, in main
    state = setup_state(args)
  File "/home/florian/tmp/tox/src/tox/run.py", line 53, in setup_state
    options = get_options(*args)
  File "/home/florian/tmp/tox/src/tox/config/cli/parse.py", line 39, in get_options
    parsed, cmd_handlers = _get_all(args)
                           ~~~~~~~~^^^^^^
  File "/home/florian/tmp/tox/src/tox/config/cli/parse.py", line 69, in _get_all
    tox_parser = _get_parser()
  File "/home/florian/tmp/tox/src/tox/config/cli/parse.py", line 76, in _get_parser
    tox_parser = ToxParser.core()  # load the core options
  File "/home/florian/tmp/tox/src/tox/config/cli/parser.py", line 300, in core
    return cls(
        prog=NAME,
    ...<3 lines>...
        description="create and set up environments to run command(s) in them",
    )
  File "/home/florian/tmp/tox/src/tox/config/cli/parser.py", line 149, in __init__
    super().__init__(*args, **kwargs)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/florian/tmp/tox/src/tox/config/cli/parser.py", line 39, in __init__
    super().__init__(*args, **kwargs)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/argparse.py", line 1920, in __init__
    self.add_argument(
    ~~~~~~~~~~~~~~~~~^
        default_prefix+'h', default_prefix*2+'help',
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        action='help', default=SUPPRESS,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        help=_('show this help message and exit'))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/florian/tmp/tox/src/tox/config/cli/parser.py", line 284, in add_argument
    result = super().add_argument(*args, **kwargs)
  File "/usr/lib/python3.14/argparse.py", line 1562, in add_argument
    formatter = self._get_formatter()
  File "/usr/lib/python3.14/argparse.py", line 2729, in _get_formatter
    return self.formatter_class(
           ~~~~~~~~~~~~~~~~~~~~^
        prog=self.prog,
        ^^^^^^^^^^^^^^^
        prefix_chars=self.prefix_chars,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        color=self.color,
        ^^^^^^^^^^^^^^^^^
    )
    ^
TypeError: HelpFormatter.__init__() got an unexpected keyword argument 'prefix_chars'
@The-Compiler The-Compiler changed the title Python 3.14: Python 3.14: TypeError: HelpFormatter.__init__() got an unexpected keyword argument 'prefix_chars' May 8, 2025
The-Compiler added a commit to The-Compiler/tox that referenced this issue May 8, 2025
python/cpython#132323 passes prefix_chars=
(and other arguments) to the formatter_class, but the custom HelpFormatter only
accepted prog=.

Accept any keyword arguments and pass them on to the parent class.

Fixes tox-dev#3523
@The-Compiler The-Compiler linked a pull request May 8, 2025 that will close this issue
5 tasks
The-Compiler added a commit to The-Compiler/tox that referenced this issue May 8, 2025
python/cpython#132323 passes prefix_chars=
(and other arguments) to the formatter_class, but the custom HelpFormatter only
accepted prog=.

Accept any keyword arguments and pass them on to the parent class.

Fixes tox-dev#3523
The-Compiler added a commit to qutebrowser/qutebrowser that referenced this issue May 8, 2025
@hugovk
Copy link
Contributor

hugovk commented May 8, 2025

We'll also fix this in CPython for beta 2 (python/cpython#133653), but it's also helpful to if tox makes a (temporary or not) fix to enable testing beta 1, thanks!

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

Successfully merging a pull request may close this issue.

2 participants