File: argparse.pyi

package info (click to toggle)
mypy 0.470-complete-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,864 kB
  • ctags: 3,264
  • sloc: python: 21,838; makefile: 18
file content (155 lines) | stat: -rw-r--r-- 6,847 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Stubs for argparse (Python 3.4)

from typing import (
    Any, Callable, Iterable, List, IO, Optional, Sequence, Tuple, Type, Union,
    TypeVar, overload
)
import sys

_T = TypeVar('_T')


ONE_OR_MORE = ...  # type: str
OPTIONAL = ...  # type: str
PARSER = ...  # type: str
REMAINDER = ...  # type: str
SUPPRESS = ...  # type: str
ZERO_OR_MORE = ...  # type: str

class ArgumentError(Exception): ...

class ArgumentParser:
    if sys.version_info >= (3, 5):
        def __init__(self,
                     prog: Optional[str] = ...,
                     usage: Optional[str] = ...,
                     description: Optional[str] = ...,
                     epilog: Optional[str] = ...,
                     parents: Sequence[ArgumentParser] = ...,
                     formatter_class: Type[HelpFormatter] = ...,
                     prefix_chars: str = ...,
                     fromfile_prefix_chars: Optional[str] = ...,
                     argument_default: Optional[str] = ...,
                     conflict_handler: str = ...,
                     add_help: bool = ...,
                     allow_abbrev: bool = ...) -> None: ...
    else:
        def __init__(self,
                     prog: Optional[str] = ...,
                     usage: Optional[str] = ...,
                     description: Optional[str] = ...,
                     epilog: Optional[str] = ...,
                     parents: Sequence[ArgumentParser] = ...,
                     formatter_class: Type[HelpFormatter] = ...,
                     prefix_chars: str = ...,
                     fromfile_prefix_chars: Optional[str] = ...,
                     argument_default: Optional[str] = ...,
                     conflict_handler: str = ...,
                     add_help: bool = ...) -> None: ...
    def add_argument(self,
                     *name_or_flags: Union[str, Sequence[str]],
                     action: Union[str, Type[Action]] = ...,
                     nargs: Union[int, str] = ...,
                     const: Any = ...,
                     default: Any = ...,
                     type: Union[Callable[[str], _T], FileType] = ...,
                     choices: Iterable[_T] = ...,
                     required: bool = ...,
                     help: str = ...,
                     metavar: Union[str, Tuple[str, ...]] = ...,
                     dest: str = ...,
                     version: str = ...) -> None: ...  # weirdly documented
    def parse_args(self, args: Optional[Sequence[str]] = ...,
                   namespace: Optional[Namespace] = ...) -> Namespace: ...
    def add_subparsers(self, title: str = ...,
                       description: Optional[str] = ...,
                       prog: str = ...,
                       parser_class: Type[ArgumentParser] = ...,
                       action: Type[Action] = ...,
                       option_string: str = ...,
                       dest: Optional[str] = ...,
                       help: Optional[str] = ...,
                       metavar: Optional[str] = ...) -> _SubParsersAction: ...
    def add_argument_group(self, title: Optional[str] = ...,
                           description: Optional[str] = ...) -> _ArgumentGroup: ...
    def add_mutually_exclusive_group(self, required: bool = ...) -> _MutuallyExclusiveGroup: ...
    def set_defaults(self, **kwargs: Any) -> None: ...
    def get_default(self, dest: str) -> Any: ...
    def print_usage(self, file: Optional[IO[str]] = ...) -> None: ...
    def print_help(self, file: Optional[IO[str]] = ...) -> None: ...
    def format_usage(self) -> str: ...
    def format_help(self) -> str: ...
    def parse_known_args(self, args: Optional[Sequence[str]] = ...,
                         namespace: Optional[Namespace] = ...) -> Tuple[Namespace, List[str]]: ...
    def convert_arg_line_to_args(self, arg_line: str) -> List[str]: ...
    def exit(self, status: int = ..., message: Optional[str] = ...) -> None: ...
    def error(self, message: str) -> None: ...

class HelpFormatter:
    # not documented
    def __init__(self, prog: str, indent_increment: int = ...,
                 max_help_position: int = ...,
                 width: Optional[int] = ...) -> None: ...
class RawDescriptionHelpFormatter(HelpFormatter): ...
class RawTextHelpFormatter(HelpFormatter): ...
class ArgumentDefaultsHelpFormatter(HelpFormatter): ...
if sys.version_info >= (3,):
    class MetavarTypeHelpFormatter(HelpFormatter): ...

class Action:
    def __init__(self,
                 option_strings: Sequence[str],
                 dest: str = ...,
                 nargs: Optional[Union[int, str]] = ...,
                 const: Any = ...,
                 default: Any = ...,
                 type: Union[Callable[[str], _T], FileType, None] = ...,
                 choices: Optional[Iterable[_T]] = ...,
                 required: bool = ...,
                 help: Optional[str] = ...,
                 metavar: Union[str, Tuple[str, ...]] = ...) -> None: ...
    def __call__(self, parser: ArgumentParser, namespace: Namespace,
                 values: Union[str, Sequence[Any], None],
                 option_string: str = ...) -> None: ...

class Namespace:
    def __getattr__(self, name: str) -> Any: ...
    def __setattr__(self, name: str, value: Any) -> None: ...

class FileType:
    if sys.version_info >= (3, 4):
        def __init__(self, mode: str = ..., bufsize: int = ...,
                     encoding: Optional[str] = ...,
                     errors: Optional[str] = ...) -> None: ...
    elif sys.version_info >= (3,):
        def __init__(self,
                     mode: str = ..., bufsize: int = ...) -> None: ...
    else:
        def __init__(self,
                     mode: str = ..., bufsize: Optional[int] = ...) -> None: ...
    def __call__(self, string: str) -> IO[Any]: ...

class _ArgumentGroup:
    def add_argument(self,
                     *name_or_flags: Union[str, Sequence[str]],
                     action: Union[str, Type[Action]] = ...,
                     nargs: Union[int, str] = ...,
                     const: Any = ...,
                     default: Any = ...,
                     type: Union[Callable[[str], _T], FileType] = ...,
                     choices: Iterable[_T] = ...,
                     required: bool = ...,
                     help: str = ...,
                     metavar: Union[str, Tuple[str, ...]] = ...,
                     dest: str = ...,
                     version: str = ...) -> None: ...
    def add_mutually_exclusive_group(self, required: bool = ...) -> _MutuallyExclusiveGroup: ...

class _MutuallyExclusiveGroup(_ArgumentGroup): ...

class _SubParsersAction:
    # TODO: Type keyword args properly.
    def add_parser(self, name: str, **kwargs: Any) -> ArgumentParser: ...

# not documented
class ArgumentTypeError(Exception): ...