Skip to content

Commit 6ffa4ab

Browse files
Add new Python 3.14 argparse.ArgumentParser parameters
These are - `suggest_on_error`, added by python/cpython#124456, made keyword-only by python/cpython#133302 - `color`, added by python/cpython#132323
1 parent 4265ee7 commit 6ffa4ab

1 file changed

Lines changed: 64 additions & 16 deletions

File tree

stdlib/argparse.pyi

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,44 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
130130
_subparsers: _ArgumentGroup | None
131131

132132
# Note: the constructor arguments are also used in _SubParsersAction.add_parser.
133-
def __init__(
134-
self,
135-
prog: str | None = None,
136-
usage: str | None = None,
137-
description: str | None = None,
138-
epilog: str | None = None,
139-
parents: Sequence[ArgumentParser] = [],
140-
formatter_class: _FormatterClass = ...,
141-
prefix_chars: str = "-",
142-
fromfile_prefix_chars: str | None = None,
143-
argument_default: Any = None,
144-
conflict_handler: str = "error",
145-
add_help: bool = True,
146-
allow_abbrev: bool = True,
147-
exit_on_error: bool = True,
148-
) -> None: ...
133+
if sys.version_info >= (3, 14):
134+
def __init__(
135+
self,
136+
prog: str | None = None,
137+
usage: str | None = None,
138+
description: str | None = None,
139+
epilog: str | None = None,
140+
parents: Sequence[ArgumentParser] = [],
141+
formatter_class: _FormatterClass = ...,
142+
prefix_chars: str = "-",
143+
fromfile_prefix_chars: str | None = None,
144+
argument_default: Any = None,
145+
conflict_handler: str = "error",
146+
add_help: bool = True,
147+
allow_abbrev: bool = True,
148+
exit_on_error: bool = True,
149+
*,
150+
suggest_on_error: bool = False,
151+
color: bool = False,
152+
) -> None: ...
153+
else:
154+
def __init__(
155+
self,
156+
prog: str | None = None,
157+
usage: str | None = None,
158+
description: str | None = None,
159+
epilog: str | None = None,
160+
parents: Sequence[ArgumentParser] = [],
161+
formatter_class: _FormatterClass = ...,
162+
prefix_chars: str = "-",
163+
fromfile_prefix_chars: str | None = None,
164+
argument_default: Any = None,
165+
conflict_handler: str = "error",
166+
add_help: bool = True,
167+
allow_abbrev: bool = True,
168+
exit_on_error: bool = True,
169+
) -> None: ...
170+
149171
@overload
150172
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
151173
@overload
@@ -668,6 +690,32 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
668690

669691
# Note: `add_parser` accepts all kwargs of `ArgumentParser.__init__`. It also
670692
# accepts its own `help` and `aliases` kwargs.
693+
if sys.version_info >= (3, 14):
694+
def add_parser(
695+
self,
696+
name: str,
697+
*,
698+
deprecated: bool = False,
699+
help: str | None = ...,
700+
aliases: Sequence[str] = ...,
701+
# Kwargs from ArgumentParser constructor
702+
prog: str | None = ...,
703+
usage: str | None = ...,
704+
description: str | None = ...,
705+
epilog: str | None = ...,
706+
parents: Sequence[_ArgumentParserT] = ...,
707+
formatter_class: _FormatterClass = ...,
708+
prefix_chars: str = ...,
709+
fromfile_prefix_chars: str | None = ...,
710+
argument_default: Any = ...,
711+
conflict_handler: str = ...,
712+
add_help: bool = ...,
713+
allow_abbrev: bool = ...,
714+
exit_on_error: bool = ...,
715+
suggest_on_error: bool = ...,
716+
color: bool = ...,
717+
**kwargs: Any, # Accepting any additional kwargs for custom parser classes
718+
) -> _ArgumentParserT: ...
671719
if sys.version_info >= (3, 13):
672720
def add_parser(
673721
self,

0 commit comments

Comments
 (0)