Update argparse to 3.14 (#14005)

This commit is contained in:
Semyon Moroz
2025-05-11 11:25:40 +00:00
committed by GitHub
parent db2949804c
commit 268e1caab9
2 changed files with 77 additions and 26 deletions
+77 -25
View File
@@ -130,22 +130,44 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
_subparsers: _ArgumentGroup | None
# Note: the constructor arguments are also used in _SubParsersAction.add_parser.
def __init__(
self,
prog: str | None = None,
usage: str | None = None,
description: str | None = None,
epilog: str | None = None,
parents: Sequence[ArgumentParser] = [],
formatter_class: _FormatterClass = ...,
prefix_chars: str = "-",
fromfile_prefix_chars: str | None = None,
argument_default: Any = None,
conflict_handler: str = "error",
add_help: bool = True,
allow_abbrev: bool = True,
exit_on_error: bool = True,
) -> None: ...
if sys.version_info >= (3, 14):
def __init__(
self,
prog: str | None = None,
usage: str | None = None,
description: str | None = None,
epilog: str | None = None,
parents: Sequence[ArgumentParser] = [],
formatter_class: _FormatterClass = ...,
prefix_chars: str = "-",
fromfile_prefix_chars: str | None = None,
argument_default: Any = None,
conflict_handler: str = "error",
add_help: bool = True,
allow_abbrev: bool = True,
exit_on_error: bool = True,
*,
suggest_on_error: bool = False,
color: bool = False,
) -> None: ...
else:
def __init__(
self,
prog: str | None = None,
usage: str | None = None,
description: str | None = None,
epilog: str | None = None,
parents: Sequence[ArgumentParser] = [],
formatter_class: _FormatterClass = ...,
prefix_chars: str = "-",
fromfile_prefix_chars: str | None = None,
argument_default: Any = None,
conflict_handler: str = "error",
add_help: bool = True,
allow_abbrev: bool = True,
exit_on_error: bool = True,
) -> None: ...
@overload
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
@overload
@@ -252,7 +274,21 @@ class HelpFormatter:
def __init__(self, formatter: HelpFormatter, parent: Self | None, heading: str | None = None) -> None: ...
def format_help(self) -> str: ...
def __init__(self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None) -> None: ...
if sys.version_info >= (3, 14):
def __init__(
self,
prog: str,
indent_increment: int = 2,
max_help_position: int = 24,
width: int | None = None,
prefix_chars: str = "-",
color: bool = False,
) -> None: ...
else:
def __init__(
self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None
) -> None: ...
def _indent(self) -> None: ...
def _dedent(self) -> None: ...
def _add_item(self, func: Callable[..., str], args: Iterable[Any]) -> None: ...
@@ -431,14 +467,30 @@ class Namespace(_AttributeHolder):
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
class FileType:
# undocumented
_mode: str
_bufsize: int
_encoding: str | None
_errors: str | None
def __init__(self, mode: str = "r", bufsize: int = -1, encoding: str | None = None, errors: str | None = None) -> None: ...
def __call__(self, string: str) -> IO[Any]: ...
if sys.version_info >= (3, 14):
@deprecated("Deprecated in Python 3.14; Simply open files after parsing arguments")
class FileType:
# undocumented
_mode: str
_bufsize: int
_encoding: str | None
_errors: str | None
def __init__(
self, mode: str = "r", bufsize: int = -1, encoding: str | None = None, errors: str | None = None
) -> None: ...
def __call__(self, string: str) -> IO[Any]: ...
else:
class FileType:
# undocumented
_mode: str
_bufsize: int
_encoding: str | None
_errors: str | None
def __init__(
self, mode: str = "r", bufsize: int = -1, encoding: str | None = None, errors: str | None = None
) -> None: ...
def __call__(self, string: str) -> IO[Any]: ...
# undocumented
class _ArgumentGroup(_ActionsContainer):