python-tox/3524.patch
2025-05-12 18:03:59 +02:00

40 lines
1.6 KiB
Diff

From 3c5d56bf8bb8405d0eceef912ba4cad7d077448c Mon Sep 17 00:00:00 2001
From: Florian Bruhin <me@the-compiler.org>
Date: Thu, 8 May 2025 10:47:22 +0200
Subject: [PATCH] Fix custom HelpFormatter for Python 3.14
https://github.com/python/cpython/pull/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 #3523
---
docs/changelog/3523.bugfix.rst | 1 +
src/tox/config/cli/parser.py | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
create mode 100644 docs/changelog/3523.bugfix.rst
diff --git a/docs/changelog/3523.bugfix.rst b/docs/changelog/3523.bugfix.rst
new file mode 100644
index 000000000..3052d877e
--- /dev/null
+++ b/docs/changelog/3523.bugfix.rst
@@ -0,0 +1 @@
+Fix ``TypeError`` for ``HelpFormatter`` with Python 3.14
diff --git a/src/tox/config/cli/parser.py b/src/tox/config/cli/parser.py
index 87629ae49..904ff7aad 100644
--- a/src/tox/config/cli/parser.py
+++ b/src/tox/config/cli/parser.py
@@ -95,8 +95,8 @@ def parse_args( # type: ignore[override] # avoid defining all overloads
class HelpFormatter(ArgumentDefaultsHelpFormatter):
"""A help formatter that provides the default value and the source it comes from."""
- def __init__(self, prog: str) -> None:
- super().__init__(prog, max_help_position=30, width=240)
+ def __init__(self, prog: str, **kwargs: Any) -> None:
+ super().__init__(prog, max_help_position=30, width=240, **kwargs)
def _get_help_string(self, action: Action) -> str | None:
text: str = super()._get_help_string(action) or ""