massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / argparse.pyi
1 import sys
2 from typing import (
3     IO,
4     Any,
5     Callable,
6     Generator,
7     Generic,
8     Iterable,
9     NoReturn,
10     Pattern,
11     Protocol,
12     Sequence,
13     Tuple,
14     Type,
15     TypeVar,
16     overload,
17 )
18
19 _T = TypeVar("_T")
20 _ActionT = TypeVar("_ActionT", bound=Action)
21 _ArgumentParserT = TypeVar("_ArgumentParserT", bound=ArgumentParser)
22 _N = TypeVar("_N")
23
24 ONE_OR_MORE: str
25 OPTIONAL: str
26 PARSER: str
27 REMAINDER: str
28 SUPPRESS: str
29 ZERO_OR_MORE: str
30 _UNRECOGNIZED_ARGS_ATTR: str  # undocumented
31
32 class ArgumentError(Exception):
33     argument_name: str | None
34     message: str
35     def __init__(self, argument: Action | None, message: str) -> None: ...
36
37 # undocumented
38 class _AttributeHolder:
39     def _get_kwargs(self) -> list[tuple[str, Any]]: ...
40     def _get_args(self) -> list[Any]: ...
41
42 # undocumented
43 class _ActionsContainer:
44     description: str | None
45     prefix_chars: str
46     argument_default: Any
47     conflict_handler: str
48
49     _registries: dict[str, dict[Any, Any]]
50     _actions: list[Action]
51     _option_string_actions: dict[str, Action]
52     _action_groups: list[_ArgumentGroup]
53     _mutually_exclusive_groups: list[_MutuallyExclusiveGroup]
54     _defaults: dict[str, Any]
55     _negative_number_matcher: Pattern[str]
56     _has_negative_number_optionals: list[bool]
57     def __init__(self, description: str | None, prefix_chars: str, argument_default: Any, conflict_handler: str) -> None: ...
58     def register(self, registry_name: str, value: Any, object: Any) -> None: ...
59     def _registry_get(self, registry_name: str, value: Any, default: Any = ...) -> Any: ...
60     def set_defaults(self, **kwargs: Any) -> None: ...
61     def get_default(self, dest: str) -> Any: ...
62     def add_argument(
63         self,
64         *name_or_flags: str,
65         action: str | Type[Action] = ...,
66         nargs: int | str = ...,
67         const: Any = ...,
68         default: Any = ...,
69         type: Callable[[str], _T] | Callable[[str], _T] | FileType = ...,
70         choices: Iterable[_T] | None = ...,
71         required: bool = ...,
72         help: str | None = ...,
73         metavar: str | Tuple[str, ...] | None = ...,
74         dest: str | None = ...,
75         version: str = ...,
76         **kwargs: Any,
77     ) -> Action: ...
78     def add_argument_group(self, *args: Any, **kwargs: Any) -> _ArgumentGroup: ...
79     def add_mutually_exclusive_group(self, **kwargs: Any) -> _MutuallyExclusiveGroup: ...
80     def _add_action(self, action: _ActionT) -> _ActionT: ...
81     def _remove_action(self, action: Action) -> None: ...
82     def _add_container_actions(self, container: _ActionsContainer) -> None: ...
83     def _get_positional_kwargs(self, dest: str, **kwargs: Any) -> dict[str, Any]: ...
84     def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
85     def _pop_action_class(self, kwargs: Any, default: Type[Action] | None = ...) -> Type[Action]: ...
86     def _get_handler(self) -> Callable[[Action, Iterable[tuple[str, Action]]], Any]: ...
87     def _check_conflict(self, action: Action) -> None: ...
88     def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> NoReturn: ...
89     def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> None: ...
90
91 class _FormatterClass(Protocol):
92     def __call__(self, prog: str) -> HelpFormatter: ...
93
94 class ArgumentParser(_AttributeHolder, _ActionsContainer):
95     prog: str
96     usage: str | None
97     epilog: str | None
98     formatter_class: _FormatterClass
99     fromfile_prefix_chars: str | None
100     add_help: bool
101     allow_abbrev: bool
102
103     # undocumented
104     _positionals: _ArgumentGroup
105     _optionals: _ArgumentGroup
106     _subparsers: _ArgumentGroup | None
107
108     if sys.version_info >= (3, 9):
109         def __init__(
110             self,
111             prog: str | None = ...,
112             usage: str | None = ...,
113             description: str | None = ...,
114             epilog: str | None = ...,
115             parents: Sequence[ArgumentParser] = ...,
116             formatter_class: _FormatterClass = ...,
117             prefix_chars: str = ...,
118             fromfile_prefix_chars: str | None = ...,
119             argument_default: Any = ...,
120             conflict_handler: str = ...,
121             add_help: bool = ...,
122             allow_abbrev: bool = ...,
123             exit_on_error: bool = ...,
124         ) -> None: ...
125     else:
126         def __init__(
127             self,
128             prog: str | None = ...,
129             usage: str | None = ...,
130             description: str | None = ...,
131             epilog: str | None = ...,
132             parents: Sequence[ArgumentParser] = ...,
133             formatter_class: _FormatterClass = ...,
134             prefix_chars: str = ...,
135             fromfile_prefix_chars: str | None = ...,
136             argument_default: Any = ...,
137             conflict_handler: str = ...,
138             add_help: bool = ...,
139             allow_abbrev: bool = ...,
140         ) -> None: ...
141     # The type-ignores in these overloads should be temporary.  See:
142     # https://github.com/python/typeshed/pull/2643#issuecomment-442280277
143     @overload
144     def parse_args(self, args: Sequence[str] | None = ...) -> Namespace: ...
145     @overload
146     def parse_args(self, args: Sequence[str] | None, namespace: None) -> Namespace: ...  # type: ignore
147     @overload
148     def parse_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
149     @overload
150     def parse_args(self, *, namespace: None) -> Namespace: ...  # type: ignore
151     @overload
152     def parse_args(self, *, namespace: _N) -> _N: ...
153     if sys.version_info >= (3, 7):
154         @overload
155         def add_subparsers(
156             self: _ArgumentParserT,
157             *,
158             title: str = ...,
159             description: str | None = ...,
160             prog: str = ...,
161             action: Type[Action] = ...,
162             option_string: str = ...,
163             dest: str | None = ...,
164             required: bool = ...,
165             help: str | None = ...,
166             metavar: str | None = ...,
167         ) -> _SubParsersAction[_ArgumentParserT]: ...
168         @overload
169         def add_subparsers(
170             self,
171             *,
172             title: str = ...,
173             description: str | None = ...,
174             prog: str = ...,
175             parser_class: Type[_ArgumentParserT] = ...,
176             action: Type[Action] = ...,
177             option_string: str = ...,
178             dest: str | None = ...,
179             required: bool = ...,
180             help: str | None = ...,
181             metavar: str | None = ...,
182         ) -> _SubParsersAction[_ArgumentParserT]: ...
183     else:
184         @overload
185         def add_subparsers(
186             self: _ArgumentParserT,
187             *,
188             title: str = ...,
189             description: str | None = ...,
190             prog: str = ...,
191             action: Type[Action] = ...,
192             option_string: str = ...,
193             dest: str | None = ...,
194             help: str | None = ...,
195             metavar: str | None = ...,
196         ) -> _SubParsersAction[_ArgumentParserT]: ...
197         @overload
198         def add_subparsers(
199             self,
200             *,
201             title: str = ...,
202             description: str | None = ...,
203             prog: str = ...,
204             parser_class: Type[_ArgumentParserT] = ...,
205             action: Type[Action] = ...,
206             option_string: str = ...,
207             dest: str | None = ...,
208             help: str | None = ...,
209             metavar: str | None = ...,
210         ) -> _SubParsersAction[_ArgumentParserT]: ...
211     def print_usage(self, file: IO[str] | None = ...) -> None: ...
212     def print_help(self, file: IO[str] | None = ...) -> None: ...
213     def format_usage(self) -> str: ...
214     def format_help(self) -> str: ...
215     def parse_known_args(
216         self, args: Sequence[str] | None = ..., namespace: Namespace | None = ...
217     ) -> tuple[Namespace, list[str]]: ...
218     def convert_arg_line_to_args(self, arg_line: str) -> list[str]: ...
219     def exit(self, status: int = ..., message: str | None = ...) -> NoReturn: ...
220     def error(self, message: str) -> NoReturn: ...
221     if sys.version_info >= (3, 7):
222         def parse_intermixed_args(self, args: Sequence[str] | None = ..., namespace: Namespace | None = ...) -> Namespace: ...
223         def parse_known_intermixed_args(
224             self, args: Sequence[str] | None = ..., namespace: Namespace | None = ...
225         ) -> tuple[Namespace, list[str]]: ...
226     # undocumented
227     def _get_optional_actions(self) -> list[Action]: ...
228     def _get_positional_actions(self) -> list[Action]: ...
229     def _parse_known_args(self, arg_strings: list[str], namespace: Namespace) -> tuple[Namespace, list[str]]: ...
230     def _read_args_from_files(self, arg_strings: list[str]) -> list[str]: ...
231     def _match_argument(self, action: Action, arg_strings_pattern: str) -> int: ...
232     def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: str) -> list[int]: ...
233     def _parse_optional(self, arg_string: str) -> tuple[Action | None, str, str | None] | None: ...
234     def _get_option_tuples(self, option_string: str) -> list[tuple[Action, str, str | None]]: ...
235     def _get_nargs_pattern(self, action: Action) -> str: ...
236     def _get_values(self, action: Action, arg_strings: list[str]) -> Any: ...
237     def _get_value(self, action: Action, arg_string: str) -> Any: ...
238     def _check_value(self, action: Action, value: Any) -> None: ...
239     def _get_formatter(self) -> HelpFormatter: ...
240     def _print_message(self, message: str, file: IO[str] | None = ...) -> None: ...
241
242 class HelpFormatter:
243     # undocumented
244     _prog: str
245     _indent_increment: int
246     _max_help_position: int
247     _width: int
248     _current_indent: int
249     _level: int
250     _action_max_length: int
251     _root_section: Any
252     _current_section: Any
253     _whitespace_matcher: Pattern[str]
254     _long_break_matcher: Pattern[str]
255     _Section: Type[Any]  # Nested class
256     def __init__(self, prog: str, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ...) -> None: ...
257     def _indent(self) -> None: ...
258     def _dedent(self) -> None: ...
259     def _add_item(self, func: Callable[..., str], args: Iterable[Any]) -> None: ...
260     def start_section(self, heading: str | None) -> None: ...
261     def end_section(self) -> None: ...
262     def add_text(self, text: str | None) -> None: ...
263     def add_usage(
264         self, usage: str | None, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: str | None = ...
265     ) -> None: ...
266     def add_argument(self, action: Action) -> None: ...
267     def add_arguments(self, actions: Iterable[Action]) -> None: ...
268     def format_help(self) -> str: ...
269     def _join_parts(self, part_strings: Iterable[str]) -> str: ...
270     def _format_usage(
271         self, usage: str, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: str | None
272     ) -> str: ...
273     def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_ArgumentGroup]) -> str: ...
274     def _format_text(self, text: str) -> str: ...
275     def _format_action(self, action: Action) -> str: ...
276     def _format_action_invocation(self, action: Action) -> str: ...
277     def _metavar_formatter(self, action: Action, default_metavar: str) -> Callable[[int], Tuple[str, ...]]: ...
278     def _format_args(self, action: Action, default_metavar: str) -> str: ...
279     def _expand_help(self, action: Action) -> str: ...
280     def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ...
281     def _split_lines(self, text: str, width: int) -> list[str]: ...
282     def _fill_text(self, text: str, width: int, indent: str) -> str: ...
283     def _get_help_string(self, action: Action) -> str | None: ...
284     def _get_default_metavar_for_optional(self, action: Action) -> str: ...
285     def _get_default_metavar_for_positional(self, action: Action) -> str: ...
286
287 class RawDescriptionHelpFormatter(HelpFormatter): ...
288 class RawTextHelpFormatter(RawDescriptionHelpFormatter): ...
289 class ArgumentDefaultsHelpFormatter(HelpFormatter): ...
290 class MetavarTypeHelpFormatter(HelpFormatter): ...
291
292 class Action(_AttributeHolder):
293     option_strings: Sequence[str]
294     dest: str
295     nargs: int | str | None
296     const: Any
297     default: Any
298     type: Callable[[str], Any] | FileType | None
299     choices: Iterable[Any] | None
300     required: bool
301     help: str | None
302     metavar: str | Tuple[str, ...] | None
303     def __init__(
304         self,
305         option_strings: Sequence[str],
306         dest: str,
307         nargs: int | str | None = ...,
308         const: _T | None = ...,
309         default: _T | str | None = ...,
310         type: Callable[[str], _T] | Callable[[str], _T] | FileType | None = ...,
311         choices: Iterable[_T] | None = ...,
312         required: bool = ...,
313         help: str | None = ...,
314         metavar: str | Tuple[str, ...] | None = ...,
315     ) -> None: ...
316     def __call__(
317         self, parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, option_string: str | None = ...
318     ) -> None: ...
319     if sys.version_info >= (3, 9):
320         def format_usage(self) -> str: ...
321
322 if sys.version_info >= (3, 9):
323     class BooleanOptionalAction(Action):
324         def __init__(
325             self,
326             option_strings: Sequence[str],
327             dest: str,
328             default: _T | str | None = ...,
329             type: Callable[[str], _T] | Callable[[str], _T] | FileType | None = ...,
330             choices: Iterable[_T] | None = ...,
331             required: bool = ...,
332             help: str | None = ...,
333             metavar: str | Tuple[str, ...] | None = ...,
334         ) -> None: ...
335
336 class Namespace(_AttributeHolder):
337     def __init__(self, **kwargs: Any) -> None: ...
338     def __getattr__(self, name: str) -> Any: ...
339     def __setattr__(self, name: str, value: Any) -> None: ...
340     def __contains__(self, key: str) -> bool: ...
341
342 class FileType:
343     # undocumented
344     _mode: str
345     _bufsize: int
346     _encoding: str | None
347     _errors: str | None
348     def __init__(self, mode: str = ..., bufsize: int = ..., encoding: str | None = ..., errors: str | None = ...) -> None: ...
349     def __call__(self, string: str) -> IO[Any]: ...
350
351 # undocumented
352 class _ArgumentGroup(_ActionsContainer):
353     title: str | None
354     _group_actions: list[Action]
355     def __init__(
356         self, container: _ActionsContainer, title: str | None = ..., description: str | None = ..., **kwargs: Any
357     ) -> None: ...
358
359 # undocumented
360 class _MutuallyExclusiveGroup(_ArgumentGroup):
361     required: bool
362     _container: _ActionsContainer
363     def __init__(self, container: _ActionsContainer, required: bool = ...) -> None: ...
364
365 # undocumented
366 class _StoreAction(Action): ...
367
368 # undocumented
369 class _StoreConstAction(Action):
370     def __init__(
371         self,
372         option_strings: Sequence[str],
373         dest: str,
374         const: Any,
375         default: Any = ...,
376         required: bool = ...,
377         help: str | None = ...,
378         metavar: str | Tuple[str, ...] | None = ...,
379     ) -> None: ...
380
381 # undocumented
382 class _StoreTrueAction(_StoreConstAction):
383     def __init__(
384         self, option_strings: Sequence[str], dest: str, default: bool = ..., required: bool = ..., help: str | None = ...
385     ) -> None: ...
386
387 # undocumented
388 class _StoreFalseAction(_StoreConstAction):
389     def __init__(
390         self, option_strings: Sequence[str], dest: str, default: bool = ..., required: bool = ..., help: str | None = ...
391     ) -> None: ...
392
393 # undocumented
394 class _AppendAction(Action): ...
395
396 # undocumented
397 class _AppendConstAction(Action):
398     def __init__(
399         self,
400         option_strings: Sequence[str],
401         dest: str,
402         const: Any,
403         default: Any = ...,
404         required: bool = ...,
405         help: str | None = ...,
406         metavar: str | Tuple[str, ...] | None = ...,
407     ) -> None: ...
408
409 # undocumented
410 class _CountAction(Action):
411     def __init__(
412         self, option_strings: Sequence[str], dest: str, default: Any = ..., required: bool = ..., help: str | None = ...
413     ) -> None: ...
414
415 # undocumented
416 class _HelpAction(Action):
417     def __init__(self, option_strings: Sequence[str], dest: str = ..., default: str = ..., help: str | None = ...) -> None: ...
418
419 # undocumented
420 class _VersionAction(Action):
421     version: str | None
422     def __init__(
423         self, option_strings: Sequence[str], version: str | None = ..., dest: str = ..., default: str = ..., help: str = ...
424     ) -> None: ...
425
426 # undocumented
427 class _SubParsersAction(Action, Generic[_ArgumentParserT]):
428     _ChoicesPseudoAction: Type[Any]  # nested class
429     _prog_prefix: str
430     _parser_class: Type[_ArgumentParserT]
431     _name_parser_map: dict[str, _ArgumentParserT]
432     choices: dict[str, _ArgumentParserT]
433     _choices_actions: list[Action]
434     if sys.version_info >= (3, 7):
435         def __init__(
436             self,
437             option_strings: Sequence[str],
438             prog: str,
439             parser_class: Type[_ArgumentParserT],
440             dest: str = ...,
441             required: bool = ...,
442             help: str | None = ...,
443             metavar: str | Tuple[str, ...] | None = ...,
444         ) -> None: ...
445     else:
446         def __init__(
447             self,
448             option_strings: Sequence[str],
449             prog: str,
450             parser_class: Type[_ArgumentParserT],
451             dest: str = ...,
452             help: str | None = ...,
453             metavar: str | Tuple[str, ...] | None = ...,
454         ) -> None: ...
455     # TODO: Type keyword args properly.
456     def add_parser(self, name: str, **kwargs: Any) -> _ArgumentParserT: ...
457     def _get_subactions(self) -> list[Action]: ...
458
459 # undocumented
460 class ArgumentTypeError(Exception): ...
461
462 if sys.version_info < (3, 7):
463     # undocumented
464     def _ensure_value(namespace: Namespace, name: str, value: Any) -> Any: ...
465
466 # undocumented
467 def _get_action_name(argument: Action | None) -> str | None: ...