From 3f8a48f6cc8c8b2a85f7e4a2a87e20f7d15e51ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Sun, 11 May 2025 23:26:28 -0600 Subject: [PATCH] Add new Python 3.14 `argparse.ArgumentParser` constructor parameters (#13947) These are - `suggest_on_error`, added by https://github.com/python/cpython/pull/124456, made keyword-only by https://github.com/python/cpython/pull/133302 - `color`, added by https://github.com/python/cpython/pull/132323 Co-authored-by: Sebastian Rittau Co-authored-by: Jelle Zijlstra --- stdlib/argparse.pyi | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 0c84f52ff..95ad6c7da 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -123,6 +123,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): fromfile_prefix_chars: str | None add_help: bool allow_abbrev: bool + exit_on_error: bool + + if sys.version_info >= (3, 14): + suggest_on_error: bool + color: bool # undocumented _positionals: _ArgumentGroup @@ -720,7 +725,33 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): # Note: `add_parser` accepts all kwargs of `ArgumentParser.__init__`. It also # accepts its own `help` and `aliases` kwargs. - if sys.version_info >= (3, 13): + if sys.version_info >= (3, 14): + def add_parser( + self, + name: str, + *, + deprecated: bool = False, + help: str | None = ..., + aliases: Sequence[str] = ..., + # Kwargs from ArgumentParser constructor + prog: str | None = ..., + usage: str | None = ..., + description: str | None = ..., + epilog: str | None = ..., + parents: Sequence[_ArgumentParserT] = ..., + formatter_class: _FormatterClass = ..., + prefix_chars: str = ..., + fromfile_prefix_chars: str | None = ..., + argument_default: Any = ..., + conflict_handler: str = ..., + add_help: bool = ..., + allow_abbrev: bool = ..., + exit_on_error: bool = ..., + suggest_on_error: bool = False, + color: bool = False, + **kwargs: Any, # Accepting any additional kwargs for custom parser classes + ) -> _ArgumentParserT: ... + elif sys.version_info >= (3, 13): def add_parser( self, name: str,