Debian Codegraph @

jedi/third_party/typeshed/stdlib/argparse.pyi

raw symbols SCIP
1 import sys
2 from _typeshed import SupportsWrite, sentinel
3 from collections.abc import Callable, Generator, Iterable, Sequence
4 from re import Pattern
5 from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload, type_check_only
6 from typing_extensions import Self, TypeAlias, deprecated
7
8 __all__ = [
9 "ArgumentParser",
10 "ArgumentError",
11 "ArgumentTypeError",
12 "FileType",
13 "HelpFormatter",
14 "ArgumentDefaultsHelpFormatter",
15 "RawDescriptionHelpFormatter",
16 "RawTextHelpFormatter",
17 "MetavarTypeHelpFormatter",
18 "Namespace",
19 "Action",
20 "BooleanOptionalAction",
21 "ONE_OR_MORE",
22 "OPTIONAL",
23 "PARSER",
24 "REMAINDER",
25 "SUPPRESS",
26 "ZERO_OR_MORE",
27 ]
28
29 _T = TypeVar("_T")
30 _ActionT = TypeVar("_ActionT", bound=Action)
31 _ArgumentParserT = TypeVar("_ArgumentParserT", bound=ArgumentParser)
32 _N = TypeVar("_N")
33 _ActionType: TypeAlias = Callable[[str], Any] | FileType | str
34
35 ONE_OR_MORE: Final = "+"
36 OPTIONAL: Final = "?"
37 PARSER: Final = "A..."
38 REMAINDER: Final = "..."
39 SUPPRESS: Final = "==SUPPRESS=="
40 ZERO_OR_MORE: Final = "*"
41 _UNRECOGNIZED_ARGS_ATTR: Final = "_unrecognized_args" # undocumented
42
43 class ArgumentError(Exception):
44 argument_name: str | None
45 message: str
46 def __init__(self, argument: Action | None, message: str) -> None: ...
47
48 # undocumented
49 class _AttributeHolder:
50 def _get_kwargs(self) -> list[tuple[str, Any]]: ...
51 def _get_args(self) -> list[Any]: ...
52
53 # undocumented
54 class _ActionsContainer:
55 description: str | None
56 prefix_chars: str
57 argument_default: Any
58 conflict_handler: str
59
60 _registries: dict[str, dict[Any, Any]]
61 _actions: list[Action]
62 _option_string_actions: dict[str, Action]
63 _action_groups: list[_ArgumentGroup]
64 _mutually_exclusive_groups: list[_MutuallyExclusiveGroup]
65 _defaults: dict[str, Any]
66 _negative_number_matcher: Pattern[str]
67 _has_negative_number_optionals: list[bool]
68 def __init__(self, description: str | None, prefix_chars: str, argument_default: Any, conflict_handler: str) -> None: ...
69 def register(self, registry_name: str, value: Any, object: Any) -> None: ...
70 def _registry_get(self, registry_name: str, value: Any, default: Any = None) -> Any: ...
71 def set_defaults(self, **kwargs: Any) -> None: ...
72 def get_default(self, dest: str) -> Any: ...
73 def add_argument(
74 self,
75 *name_or_flags: str,
76 # str covers predefined actions ("store_true", "count", etc.)
77 # and user registered actions via the `register` method.
78 action: str | type[Action] = ...,
79 # more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
80 # but using this would make it hard to annotate callers that don't use a
81 # literal argument and for subclasses to override this method.
82 nargs: int | str | None = None,
83 const: Any = ...,
84 default: Any = ...,
85 type: _ActionType = ...,
86 choices: Iterable[Any] | None = ..., # choices must match the type specified
87 required: bool = ...,
88 help: str | None = ...,
89 metavar: str | tuple[str, ...] | None = ...,
90 dest: str | None = ...,
91 version: str = ...,
92 **kwargs: Any,
93 ) -> Action: ...
94 if sys.version_info >= (3, 14):
95 @overload
96 def add_argument_group(
97 self,
98 title: str | None = None,
99 description: str | None = None,
100 *,
101 # argument_default's type must be valid for the arguments in the group
102 argument_default: Any = ...,
103 conflict_handler: str = ...,
104 ) -> _ArgumentGroup: ...
105 @overload
106 @deprecated("The `prefix_chars` parameter deprecated since Python 3.14.")
107 def add_argument_group(
108 self,
109 title: str | None = None,
110 description: str | None = None,
111 *,
112 prefix_chars: str,
113 argument_default: Any = ...,
114 conflict_handler: str = ...,
115 ) -> _ArgumentGroup: ...
116 else:
117 def add_argument_group(
118 self,
119 title: str | None = None,
120 description: str | None = None,
121 *,
122 prefix_chars: str = ...,
123 # argument_default's type must be valid for the arguments in the group
124 argument_default: Any = ...,
125 conflict_handler: str = ...,
126 ) -> _ArgumentGroup: ...
127
128 def add_mutually_exclusive_group(self, *, required: bool = False) -> _MutuallyExclusiveGroup: ...
129 def _add_action(self, action: _ActionT) -> _ActionT: ...
130 def _remove_action(self, action: Action) -> None: ...
131 def _add_container_actions(self, container: _ActionsContainer) -> None: ...
132 def _get_positional_kwargs(self, dest: str, **kwargs: Any) -> dict[str, Any]: ...
133 def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
134 def _pop_action_class(self, kwargs: Any, default: type[Action] | None = None) -> type[Action]: ...
135 def _get_handler(self) -> Callable[[Action, Iterable[tuple[str, Action]]], Any]: ...
136 def _check_conflict(self, action: Action) -> None: ...
137 def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> NoReturn: ...
138 def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> None: ...
139
140 @type_check_only
141 class _FormatterClass(Protocol):
142 def __call__(self, *, prog: str) -> HelpFormatter: ...
143
144 class ArgumentParser(_AttributeHolder, _ActionsContainer):
145 prog: str
146 usage: str | None
147 epilog: str | None
148 formatter_class: _FormatterClass
149 fromfile_prefix_chars: str | None
150 add_help: bool
151 allow_abbrev: bool
152 exit_on_error: bool
153
154 if sys.version_info >= (3, 14):
155 suggest_on_error: bool
156 color: bool
157
158 # undocumented
159 _positionals: _ArgumentGroup
160 _optionals: _ArgumentGroup
161 _subparsers: _ArgumentGroup | None
162
163 # Note: the constructor arguments are also used in _SubParsersAction.add_parser.
164 if sys.version_info >= (3, 14):
165 def __init__(
166 self,
167 prog: str | None = None,
168 usage: str | None = None,
169 description: str | None = None,
170 epilog: str | None = None,
171 parents: Iterable[ArgumentParser] = [],
172 formatter_class: _FormatterClass = ...,
173 prefix_chars: str = "-",
174 fromfile_prefix_chars: str | None = None,
175 argument_default: Any = None,
176 conflict_handler: str = "error",
177 add_help: bool = True,
178 allow_abbrev: bool = True,
179 exit_on_error: bool = True,
180 *,
181 suggest_on_error: bool = False,
182 color: bool = True,
183 ) -> None: ...
184 else:
185 def __init__(
186 self,
187 prog: str | None = None,
188 usage: str | None = None,
189 description: str | None = None,
190 epilog: str | None = None,
191 parents: Iterable[ArgumentParser] = [],
192 formatter_class: _FormatterClass = ...,
193 prefix_chars: str = "-",
194 fromfile_prefix_chars: str | None = None,
195 argument_default: Any = None,
196 conflict_handler: str = "error",
197 add_help: bool = True,
198 allow_abbrev: bool = True,
199 exit_on_error: bool = True,
200 ) -> None: ...
201
202 @overload
203 def parse_args(self, args: Iterable[str] | None = None, namespace: None = None) -> Namespace: ...
204 @overload
205 def parse_args(self, args: Iterable[str] | None, namespace: _N) -> _N: ...
206 @overload
207 def parse_args(self, *, namespace: _N) -> _N: ...
208 @overload
209 def add_subparsers(
210 self: _ArgumentParserT,
211 *,
212 title: str = "subcommands",
213 description: str | None = None,
214 prog: str | None = None,
215 action: type[Action] = ...,
216 option_string: str = ...,
217 dest: str | None = None,
218 required: bool = False,
219 help: str | None = None,
220 metavar: str | None = None,
221 ) -> _SubParsersAction[_ArgumentParserT]: ...
222 @overload
223 def add_subparsers(
224 self,
225 *,
226 title: str = "subcommands",
227 description: str | None = None,
228 prog: str | None = None,
229 parser_class: type[_ArgumentParserT],
230 action: type[Action] = ...,
231 option_string: str = ...,
232 dest: str | None = None,
233 required: bool = False,
234 help: str | None = None,
235 metavar: str | None = None,
236 ) -> _SubParsersAction[_ArgumentParserT]: ...
237 def print_usage(self, file: SupportsWrite[str] | None = None) -> None: ...
238 def print_help(self, file: SupportsWrite[str] | None = None) -> None: ...
239 def format_usage(self) -> str: ...
240 def format_help(self) -> str: ...
241 @overload
242 def parse_known_args(self, args: Iterable[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ...
243 @overload
244 def parse_known_args(self, args: Iterable[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
245 @overload
246 def parse_known_args(self, *, namespace: _N) -> tuple[_N, list[str]]: ...
247 def convert_arg_line_to_args(self, arg_line: str) -> list[str]: ...
248 def exit(self, status: int = 0, message: str | None = None) -> NoReturn: ...
249 def error(self, message: str) -> NoReturn: ...
250 @overload
251 def parse_intermixed_args(self, args: Iterable[str] | None = None, namespace: None = None) -> Namespace: ...
252 @overload
253 def parse_intermixed_args(self, args: Iterable[str] | None, namespace: _N) -> _N: ...
254 @overload
255 def parse_intermixed_args(self, *, namespace: _N) -> _N: ...
256 @overload
257 def parse_known_intermixed_args(
258 self, args: Iterable[str] | None = None, namespace: None = None
259 ) -> tuple[Namespace, list[str]]: ...
260 @overload
261 def parse_known_intermixed_args(self, args: Iterable[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
262 @overload
263 def parse_known_intermixed_args(self, *, namespace: _N) -> tuple[_N, list[str]]: ...
264 # undocumented
265 def _get_optional_actions(self) -> list[Action]: ...
266 def _get_positional_actions(self) -> list[Action]: ...
267 if sys.version_info >= (3, 12):
268 def _parse_known_args(
269 self, arg_strings: list[str], namespace: Namespace, intermixed: bool
270 ) -> tuple[Namespace, list[str]]: ...
271 else:
272 def _parse_known_args(self, arg_strings: list[str], namespace: Namespace) -> tuple[Namespace, list[str]]: ...
273
274 def _read_args_from_files(self, arg_strings: list[str]) -> list[str]: ...
275 def _match_argument(self, action: Action, arg_strings_pattern: str) -> int: ...
276 def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: str) -> list[int]: ...
277 if sys.version_info >= (3, 12):
278 def _parse_optional(self, arg_string: str) -> list[tuple[Action | None, str, str | None, str | None]] | None: ...
279 else:
280 def _parse_optional(self, arg_string: str) -> tuple[Action | None, str, str | None] | None: ...
281
282 def _get_option_tuples(self, option_string: str) -> list[tuple[Action, str, str | None]]: ...
283 def _get_nargs_pattern(self, action: Action) -> str: ...
284 def _get_values(self, action: Action, arg_strings: list[str]) -> Any: ...
285 def _get_value(self, action: Action, arg_string: str) -> Any: ...
286 def _check_value(self, action: Action, value: Any) -> None: ...
287 def _get_formatter(self) -> HelpFormatter: ...
288 def _print_message(self, message: str, file: SupportsWrite[str] | None = None) -> None: ...
289
290 class HelpFormatter:
291 # undocumented
292 _prog: str
293 _indent_increment: int
294 _max_help_position: int
295 _width: int
296 _current_indent: int
297 _level: int
298 _action_max_length: int
299 _root_section: _Section
300 _current_section: _Section
301 _whitespace_matcher: Pattern[str]
302 _long_break_matcher: Pattern[str]
303
304 class _Section:
305 formatter: HelpFormatter
306 heading: str | None
307 parent: Self | None
308 items: list[tuple[Callable[..., str], Iterable[Any]]]
309 def __init__(self, formatter: HelpFormatter, parent: Self | None, heading: str | None = None) -> None: ...
310 def format_help(self) -> str: ...
311
312 if sys.version_info >= (3, 14):
313 def __init__(
314 self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None, color: bool = True
315 ) -> None: ...
316 else:
317 def __init__(
318 self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None
319 ) -> None: ...
320
321 def _indent(self) -> None: ...
322 def _dedent(self) -> None: ...
323 def _add_item(self, func: Callable[..., str], args: Iterable[Any]) -> None: ...
324 def start_section(self, heading: str | None) -> None: ...
325 def end_section(self) -> None: ...
326 def add_text(self, text: str | None) -> None: ...
327 def add_usage(
328 self, usage: str | None, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup], prefix: str | None = None
329 ) -> None: ...
330 def add_argument(self, action: Action) -> None: ...
331 def add_arguments(self, actions: Iterable[Action]) -> None: ...
332 def format_help(self) -> str: ...
333 def _join_parts(self, part_strings: Iterable[str]) -> str: ...
334 def _format_usage(
335 self, usage: str | None, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup], prefix: str | None
336 ) -> str: ...
337 if sys.version_info < (3, 14):
338 # Removed in Python 3.14.3
339 def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup]) -> str: ...
340
341 def _format_text(self, text: str) -> str: ...
342 def _format_action(self, action: Action) -> str: ...
343 def _format_action_invocation(self, action: Action) -> str: ...
344 def _metavar_formatter(self, action: Action, default_metavar: str) -> Callable[[int], tuple[str, ...]]: ...
345 def _format_args(self, action: Action, default_metavar: str) -> str: ...
346 def _expand_help(self, action: Action) -> str: ...
347 def _iter_indented_subactions(self, action: Action) -> Generator[Action]: ...
348 def _split_lines(self, text: str, width: int) -> list[str]: ...
349 def _fill_text(self, text: str, width: int, indent: str) -> str: ...
350 def _get_help_string(self, action: Action) -> str | None: ...
351 def _get_default_metavar_for_optional(self, action: Action) -> str: ...
352 def _get_default_metavar_for_positional(self, action: Action) -> str: ...
353
354 class RawDescriptionHelpFormatter(HelpFormatter): ...
355 class RawTextHelpFormatter(RawDescriptionHelpFormatter): ...
356 class ArgumentDefaultsHelpFormatter(HelpFormatter): ...
357 class MetavarTypeHelpFormatter(HelpFormatter): ...
358
359 class Action(_AttributeHolder):
360 option_strings: Sequence[str]
361 dest: str
362 nargs: int | str | None
363 const: Any
364 default: Any
365 type: _ActionType | None
366 choices: Iterable[Any] | None
367 required: bool
368 help: str | None
369 metavar: str | tuple[str, ...] | None
370 if sys.version_info >= (3, 13):
371 def __init__(
372 self,
373 option_strings: Sequence[str],
374 dest: str,
375 nargs: int | str | None = None,
376 const: _T | None = None,
377 default: _T | str | None = None,
378 type: Callable[[str], _T] | FileType | None = None,
379 choices: Iterable[_T] | None = None,
380 required: bool = False,
381 help: str | None = None,
382 metavar: str | tuple[str, ...] | None = None,
383 deprecated: bool = False,
384 ) -> None: ...
385 else:
386 def __init__(
387 self,
388 option_strings: Sequence[str],
389 dest: str,
390 nargs: int | str | None = None,
391 const: _T | None = None,
392 default: _T | str | None = None,
393 type: Callable[[str], _T] | FileType | None = None,
394 choices: Iterable[_T] | None = None,
395 required: bool = False,
396 help: str | None = None,
397 metavar: str | tuple[str, ...] | None = None,
398 ) -> None: ...
399
400 def __call__(
401 self, parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, option_string: str | None = None
402 ) -> None: ...
403 def format_usage(self) -> str: ...
404
405 if sys.version_info >= (3, 12):
406 class BooleanOptionalAction(Action):
407 if sys.version_info >= (3, 14):
408 def __init__(
409 self,
410 option_strings: Sequence[str],
411 dest: str,
412 default: bool | None = None,
413 required: bool = False,
414 help: str | None = None,
415 deprecated: bool = False,
416 ) -> None: ...
417 elif sys.version_info >= (3, 13):
418 @overload
419 def __init__(
420 self,
421 option_strings: Sequence[str],
422 dest: str,
423 default: bool | None = None,
424 *,
425 required: bool = False,
426 help: str | None = None,
427 deprecated: bool = False,
428 ) -> None: ...
429 @overload
430 @deprecated("The `type`, `choices`, and `metavar` parameters are ignored and will be removed in Python 3.14.")
431 def __init__(
432 self,
433 option_strings: Sequence[str],
434 dest: str,
435 default: _T | bool | None = None,
436 type: Callable[[str], _T] | FileType | None = sentinel,
437 choices: Iterable[_T] | None = sentinel,
438 required: bool = False,
439 help: str | None = None,
440 metavar: str | tuple[str, ...] | None = sentinel,
441 deprecated: bool = False,
442 ) -> None: ...
443 else:
444 @overload
445 def __init__(
446 self,
447 option_strings: Sequence[str],
448 dest: str,
449 default: bool | None = None,
450 *,
451 required: bool = False,
452 help: str | None = None,
453 ) -> None: ...
454 @overload
455 @deprecated("The `type`, `choices`, and `metavar` parameters are ignored and will be removed in Python 3.14.")
456 def __init__(
457 self,
458 option_strings: Sequence[str],
459 dest: str,
460 default: _T | bool | None = None,
461 type: Callable[[str], _T] | FileType | None = sentinel,
462 choices: Iterable[_T] | None = sentinel,
463 required: bool = False,
464 help: str | None = None,
465 metavar: str | tuple[str, ...] | None = sentinel,
466 ) -> None: ...
467
468 else:
469 class BooleanOptionalAction(Action):
470 @overload
471 def __init__(
472 self,
473 option_strings: Sequence[str],
474 dest: str,
475 default: bool | None = None,
476 *,
477 required: bool = False,
478 help: str | None = None,
479 ) -> None: ...
480 @overload
481 @deprecated("The `type`, `choices`, and `metavar` parameters are ignored and will be removed in Python 3.14.")
482 def __init__(
483 self,
484 option_strings: Sequence[str],
485 dest: str,
486 default: _T | bool | None = None,
487 type: Callable[[str], _T] | FileType | None = None,
488 choices: Iterable[_T] | None = None,
489 required: bool = False,
490 help: str | None = None,
491 metavar: str | tuple[str, ...] | None = None,
492 ) -> None: ...
493
494 class Namespace(_AttributeHolder):
495 def __init__(self, **kwargs: Any) -> None: ...
496 def __getattr__(self, name: str) -> Any: ...
497 def __setattr__(self, name: str, value: Any, /) -> None: ...
498 def __contains__(self, key: str) -> bool: ...
499 def __eq__(self, other: object) -> bool: ...
500 __hash__: ClassVar[None] # type: ignore[assignment]
501
502 if sys.version_info >= (3, 14):
503 @deprecated("Deprecated since Python 3.14. Open files after parsing arguments instead.")
504 class FileType:
505 # undocumented
506 _mode: str
507 _bufsize: int
508 _encoding: str | None
509 _errors: str | None
510 def __init__(
511 self, mode: str = "r", bufsize: int = -1, encoding: str | None = None, errors: str | None = None
512 ) -> None: ...
513 def __call__(self, string: str) -> IO[Any]: ...
514
515 else:
516 class FileType:
517 # undocumented
518 _mode: str
519 _bufsize: int
520 _encoding: str | None
521 _errors: str | None
522 def __init__(
523 self, mode: str = "r", bufsize: int = -1, encoding: str | None = None, errors: str | None = None
524 ) -> None: ...
525 def __call__(self, string: str) -> IO[Any]: ...
526
527 # undocumented
528 class _ArgumentGroup(_ActionsContainer):
529 title: str | None
530 _group_actions: list[Action]
531 if sys.version_info >= (3, 14):
532 @overload
533 def __init__(
534 self,
535 container: _ActionsContainer,
536 title: str | None = None,
537 description: str | None = None,
538 *,
539 argument_default: Any = ...,
540 conflict_handler: str = ...,
541 ) -> None: ...
542 @overload
543 @deprecated("Undocumented `prefix_chars` parameter is deprecated since Python 3.14.")
544 def __init__(
545 self,
546 container: _ActionsContainer,
547 title: str | None = None,
548 description: str | None = None,
549 *,
550 prefix_chars: str,
551 argument_default: Any = ...,
552 conflict_handler: str = ...,
553 ) -> None: ...
554 else:
555 def __init__(
556 self,
557 container: _ActionsContainer,
558 title: str | None = None,
559 description: str | None = None,
560 *,
561 prefix_chars: str = ...,
562 argument_default: Any = ...,
563 conflict_handler: str = ...,
564 ) -> None: ...
565
566 # undocumented
567 class _MutuallyExclusiveGroup(_ArgumentGroup):
568 required: bool
569 _container: _ActionsContainer
570 def __init__(self, container: _ActionsContainer, required: bool = False) -> None: ...
571
572 # undocumented
573 class _StoreAction(Action): ...
574
575 # undocumented
576 class _StoreConstAction(Action):
577 if sys.version_info >= (3, 13):
578 def __init__(
579 self,
580 option_strings: Sequence[str],
581 dest: str,
582 const: Any | None = None,
583 default: Any = None,
584 required: bool = False,
585 help: str | None = None,
586 metavar: str | tuple[str, ...] | None = None,
587 deprecated: bool = False,
588 ) -> None: ...
589 elif sys.version_info >= (3, 11):
590 def __init__(
591 self,
592 option_strings: Sequence[str],
593 dest: str,
594 const: Any | None = None,
595 default: Any = None,
596 required: bool = False,
597 help: str | None = None,
598 metavar: str | tuple[str, ...] | None = None,
599 ) -> None: ...
600 else:
601 def __init__(
602 self,
603 option_strings: Sequence[str],
604 dest: str,
605 const: Any,
606 default: Any = None,
607 required: bool = False,
608 help: str | None = None,
609 metavar: str | tuple[str, ...] | None = None,
610 ) -> None: ...
611
612 # undocumented
613 class _StoreTrueAction(_StoreConstAction):
614 if sys.version_info >= (3, 13):
615 def __init__(
616 self,
617 option_strings: Sequence[str],
618 dest: str,
619 default: bool = False,
620 required: bool = False,
621 help: str | None = None,
622 deprecated: bool = False,
623 ) -> None: ...
624 else:
625 def __init__(
626 self, option_strings: Sequence[str], dest: str, default: bool = False, required: bool = False, help: str | None = None
627 ) -> None: ...
628
629 # undocumented
630 class _StoreFalseAction(_StoreConstAction):
631 if sys.version_info >= (3, 13):
632 def __init__(
633 self,
634 option_strings: Sequence[str],
635 dest: str,
636 default: bool = True,
637 required: bool = False,
638 help: str | None = None,
639 deprecated: bool = False,
640 ) -> None: ...
641 else:
642 def __init__(
643 self, option_strings: Sequence[str], dest: str, default: bool = True, required: bool = False, help: str | None = None
644 ) -> None: ...
645
646 # undocumented
647 class _AppendAction(Action): ...
648
649 # undocumented
650 class _ExtendAction(_AppendAction): ...
651
652 # undocumented
653 class _AppendConstAction(Action):
654 if sys.version_info >= (3, 13):
655 def __init__(
656 self,
657 option_strings: Sequence[str],
658 dest: str,
659 const: Any | None = None,
660 default: Any = None,
661 required: bool = False,
662 help: str | None = None,
663 metavar: str | tuple[str, ...] | None = None,
664 deprecated: bool = False,
665 ) -> None: ...
666 elif sys.version_info >= (3, 11):
667 def __init__(
668 self,
669 option_strings: Sequence[str],
670 dest: str,
671 const: Any | None = None,
672 default: Any = None,
673 required: bool = False,
674 help: str | None = None,
675 metavar: str | tuple[str, ...] | None = None,
676 ) -> None: ...
677 else:
678 def __init__(
679 self,
680 option_strings: Sequence[str],
681 dest: str,
682 const: Any,
683 default: Any = None,
684 required: bool = False,
685 help: str | None = None,
686 metavar: str | tuple[str, ...] | None = None,
687 ) -> None: ...
688
689 # undocumented
690 class _CountAction(Action):
691 if sys.version_info >= (3, 13):
692 def __init__(
693 self,
694 option_strings: Sequence[str],
695 dest: str,
696 default: Any = None,
697 required: bool = False,
698 help: str | None = None,
699 deprecated: bool = False,
700 ) -> None: ...
701 else:
702 def __init__(
703 self, option_strings: Sequence[str], dest: str, default: Any = None, required: bool = False, help: str | None = None
704 ) -> None: ...
705
706 # undocumented
707 class _HelpAction(Action):
708 if sys.version_info >= (3, 13):
709 def __init__(
710 self,
711 option_strings: Sequence[str],
712 dest: str = "==SUPPRESS==",
713 default: str = "==SUPPRESS==",
714 help: str | None = None,
715 deprecated: bool = False,
716 ) -> None: ...
717 else:
718 def __init__(
719 self,
720 option_strings: Sequence[str],
721 dest: str = "==SUPPRESS==",
722 default: str = "==SUPPRESS==",
723 help: str | None = None,
724 ) -> None: ...
725
726 # undocumented
727 class _VersionAction(Action):
728 version: str | None
729 if sys.version_info >= (3, 13):
730 def __init__(
731 self,
732 option_strings: Sequence[str],
733 version: str | None = None,
734 dest: str = "==SUPPRESS==",
735 default: str = "==SUPPRESS==",
736 help: str | None = None,
737 deprecated: bool = False,
738 ) -> None: ...
739 elif sys.version_info >= (3, 11):
740 def __init__(
741 self,
742 option_strings: Sequence[str],
743 version: str | None = None,
744 dest: str = "==SUPPRESS==",
745 default: str = "==SUPPRESS==",
746 help: str | None = None,
747 ) -> None: ...
748 else:
749 def __init__(
750 self,
751 option_strings: Sequence[str],
752 version: str | None = None,
753 dest: str = "==SUPPRESS==",
754 default: str = "==SUPPRESS==",
755 help: str = "show program's version number and exit",
756 ) -> None: ...
757
758 # undocumented
759 class _SubParsersAction(Action, Generic[_ArgumentParserT]):
760 _ChoicesPseudoAction: type[Any] # nested class
761 _prog_prefix: str
762 _parser_class: type[_ArgumentParserT]
763 _name_parser_map: dict[str, _ArgumentParserT]
764 choices: dict[str, _ArgumentParserT]
765 _choices_actions: list[Action]
766 def __init__(
767 self,
768 option_strings: Sequence[str],
769 prog: str,
770 parser_class: type[_ArgumentParserT],
771 dest: str = "==SUPPRESS==",
772 required: bool = False,
773 help: str | None = None,
774 metavar: str | tuple[str, ...] | None = None,
775 ) -> None: ...
776
777 # Note: `add_parser` accepts all kwargs of `ArgumentParser.__init__`. It also
778 # accepts its own `help` and `aliases` kwargs.
779 if sys.version_info >= (3, 14):
780 def add_parser(
781 self,
782 name: str,
783 *,
784 deprecated: bool = False,
785 help: str | None = ...,
786 aliases: Iterable[str] = ...,
787 # Kwargs from ArgumentParser constructor
788 prog: str | None = ...,
789 usage: str | None = ...,
790 description: str | None = ...,
791 epilog: str | None = ...,
792 parents: Iterable[_ArgumentParserT] = ...,
793 formatter_class: _FormatterClass = ...,
794 prefix_chars: str = ...,
795 fromfile_prefix_chars: str | None = ...,
796 argument_default: Any = ...,
797 conflict_handler: str = ...,
798 add_help: bool = True,
799 allow_abbrev: bool = True,
800 exit_on_error: bool = True,
801 suggest_on_error: bool = False,
802 color: bool = False,
803 **kwargs: Any, # Accepting any additional kwargs for custom parser classes
804 ) -> _ArgumentParserT: ...
805 elif sys.version_info >= (3, 13):
806 def add_parser(
807 self,
808 name: str,
809 *,
810 deprecated: bool = False,
811 help: str | None = ...,
812 aliases: Iterable[str] = ...,
813 # Kwargs from ArgumentParser constructor
814 prog: str | None = ...,
815 usage: str | None = ...,
816 description: str | None = ...,
817 epilog: str | None = ...,
818 parents: Iterable[_ArgumentParserT] = ...,
819 formatter_class: _FormatterClass = ...,
820 prefix_chars: str = ...,
821 fromfile_prefix_chars: str | None = ...,
822 argument_default: Any = ...,
823 conflict_handler: str = ...,
824 add_help: bool = True,
825 allow_abbrev: bool = True,
826 exit_on_error: bool = True,
827 **kwargs: Any, # Accepting any additional kwargs for custom parser classes
828 ) -> _ArgumentParserT: ...
829 else:
830 def add_parser(
831 self,
832 name: str,
833 *,
834 help: str | None = ...,
835 aliases: Iterable[str] = ...,
836 # Kwargs from ArgumentParser constructor
837 prog: str | None = ...,
838 usage: str | None = ...,
839 description: str | None = ...,
840 epilog: str | None = ...,
841 parents: Iterable[_ArgumentParserT] = ...,
842 formatter_class: _FormatterClass = ...,
843 prefix_chars: str = ...,
844 fromfile_prefix_chars: str | None = ...,
845 argument_default: Any = ...,
846 conflict_handler: str = ...,
847 add_help: bool = True,
848 allow_abbrev: bool = True,
849 exit_on_error: bool = True,
850 **kwargs: Any, # Accepting any additional kwargs for custom parser classes
851 ) -> _ArgumentParserT: ...
852
853 def _get_subactions(self) -> list[Action]: ...
854
855 # undocumented
856 class ArgumentTypeError(Exception): ...
857
858 # undocumented
859 def _get_action_name(argument: Action | None) -> str | None: ...