@@ -1181,7 +1181,7 @@ done downstream after the arguments are parsed.
1181
1181
For example, JSON or YAML conversions have complex error cases that require
1182
1182
better reporting than can be given by the ``type `` keyword. A
1183
1183
:exc: `~json.JSONDecodeError ` would not be well formatted and a
1184
- :exc: `FileNotFound ` exception would not be handled at all.
1184
+ :exc: `FileNotFoundError ` exception would not be handled at all.
1185
1185
1186
1186
Even :class: `~argparse.FileType ` has its limitations for use with the ``type ``
1187
1187
keyword. If one argument uses *FileType * and then a subsequent argument fails,
@@ -1435,7 +1435,7 @@ Action classes
1435
1435
Action classes implement the Action API, a callable which returns a callable
1436
1436
which processes arguments from the command-line. Any object which follows
1437
1437
this API may be passed as the ``action `` parameter to
1438
- :meth: `add_argument `.
1438
+ :meth: `~ArgumentParser. add_argument `.
1439
1439
1440
1440
.. class :: Action(option_strings, dest, nargs=None, const=None, default=None, \
1441
1441
type=None, choices=None, required=False, help=None, \
@@ -1710,7 +1710,7 @@ Sub-commands
1710
1710
:class: `ArgumentParser ` supports the creation of such sub-commands with the
1711
1711
:meth: `add_subparsers ` method. The :meth: `add_subparsers ` method is normally
1712
1712
called with no arguments and returns a special action object. This object
1713
- has a single method, :meth: `~ArgumentParser .add_parser `, which takes a
1713
+ has a single method, :meth: `~_SubParsersAction .add_parser `, which takes a
1714
1714
command name and any :class: `ArgumentParser ` constructor arguments, and
1715
1715
returns an :class: `ArgumentParser ` object that can be modified as usual.
1716
1716
@@ -1776,7 +1776,7 @@ Sub-commands
1776
1776
for that particular parser will be printed. The help message will not
1777
1777
include parent parser or sibling parser messages. (A help message for each
1778
1778
subparser command, however, can be given by supplying the ``help= `` argument
1779
- to :meth: `add_parser ` as above.)
1779
+ to :meth: `~_SubParsersAction. add_parser ` as above.)
1780
1780
1781
1781
::
1782
1782
@@ -2125,7 +2125,7 @@ the populated namespace and the list of remaining argument strings.
2125
2125
2126
2126
.. warning ::
2127
2127
:ref: `Prefix matching <prefix-matching >` rules apply to
2128
- :meth: `parse_known_args `. The parser may consume an option even if it's just
2128
+ :meth: `~ArgumentParser. parse_known_args `. The parser may consume an option even if it's just
2129
2129
a prefix of one of its known options, instead of leaving it in the remaining
2130
2130
arguments list.
2131
2131
@@ -2263,3 +2263,17 @@ A partial upgrade path from :mod:`optparse` to :mod:`argparse`:
2263
2263
2264
2264
* Replace the OptionParser constructor ``version `` argument with a call to
2265
2265
``parser.add_argument('--version', action='version', version='<the version>') ``.
2266
+
2267
+ Exceptions
2268
+ ----------
2269
+
2270
+ .. exception :: ArgumentError
2271
+
2272
+ An error from creating or using an argument (optional or positional).
2273
+
2274
+ The string value of this exception is the message, augmented with
2275
+ information about the argument that caused it.
2276
+
2277
+ .. exception :: ArgumentTypeError
2278
+
2279
+ Raised when something goes wrong converting a command line string to a type.
0 commit comments