@@ -585,7 +585,7 @@ arguments will never be treated as file references.
585
585
586
586
.. versionchanged :: 3.12
587
587
:class: `ArgumentParser ` changed encoding and errors to read arguments files
588
- from default (e.g. :func: `locale.getpreferredencoding(False) ` and
588
+ from default (e.g. :func: `locale.getpreferredencoding(False) <locale.getpreferredencoding> ` and
589
589
``"strict" ``) to :term: `filesystem encoding and error handler `.
590
590
Arguments file should be encoded in UTF-8 instead of ANSI Codepage on Windows.
591
591
@@ -1191,7 +1191,7 @@ done downstream after the arguments are parsed.
1191
1191
For example, JSON or YAML conversions have complex error cases that require
1192
1192
better reporting than can be given by the ``type `` keyword. A
1193
1193
:exc: `~json.JSONDecodeError ` would not be well formatted and a
1194
- :exc: `FileNotFound ` exception would not be handled at all.
1194
+ :exc: `FileNotFoundError ` exception would not be handled at all.
1195
1195
1196
1196
Even :class: `~argparse.FileType ` has its limitations for use with the ``type ``
1197
1197
keyword. If one argument uses *FileType * and then a subsequent argument fails,
@@ -1445,7 +1445,7 @@ Action classes
1445
1445
Action classes implement the Action API, a callable which returns a callable
1446
1446
which processes arguments from the command-line. Any object which follows
1447
1447
this API may be passed as the ``action `` parameter to
1448
- :meth: `add_argument `.
1448
+ :meth: `~ArgumentParser. add_argument `.
1449
1449
1450
1450
.. class :: Action(option_strings, dest, nargs=None, const=None, default=None, \
1451
1451
type=None, choices=None, required=False, help=None, \
@@ -1723,7 +1723,7 @@ Sub-commands
1723
1723
:class: `ArgumentParser ` supports the creation of such sub-commands with the
1724
1724
:meth: `add_subparsers ` method. The :meth: `add_subparsers ` method is normally
1725
1725
called with no arguments and returns a special action object. This object
1726
- has a single method, :meth: `~ArgumentParser .add_parser `, which takes a
1726
+ has a single method, :meth: `~_SubParsersAction .add_parser `, which takes a
1727
1727
command name and any :class: `ArgumentParser ` constructor arguments, and
1728
1728
returns an :class: `ArgumentParser ` object that can be modified as usual.
1729
1729
@@ -1789,7 +1789,7 @@ Sub-commands
1789
1789
for that particular parser will be printed. The help message will not
1790
1790
include parent parser or sibling parser messages. (A help message for each
1791
1791
subparser command, however, can be given by supplying the ``help= `` argument
1792
- to :meth: `add_parser ` as above.)
1792
+ to :meth: `~_SubParsersAction. add_parser ` as above.)
1793
1793
1794
1794
::
1795
1795
@@ -2157,7 +2157,7 @@ the populated namespace and the list of remaining argument strings.
2157
2157
2158
2158
.. warning ::
2159
2159
:ref: `Prefix matching <prefix-matching >` rules apply to
2160
- :meth: `parse_known_args `. The parser may consume an option even if it's just
2160
+ :meth: `~ArgumentParser. parse_known_args `. The parser may consume an option even if it's just
2161
2161
a prefix of one of its known options, instead of leaving it in the remaining
2162
2162
arguments list.
2163
2163
@@ -2295,3 +2295,17 @@ A partial upgrade path from :mod:`optparse` to :mod:`argparse`:
2295
2295
2296
2296
* Replace the OptionParser constructor ``version `` argument with a call to
2297
2297
``parser.add_argument('--version', action='version', version='<the version>') ``.
2298
+
2299
+ Exceptions
2300
+ ----------
2301
+
2302
+ .. exception :: ArgumentError
2303
+
2304
+ An error from creating or using an argument (optional or positional).
2305
+
2306
+ The string value of this exception is the message, augmented with
2307
+ information about the argument that caused it.
2308
+
2309
+ .. exception :: ArgumentTypeError
2310
+
2311
+ Raised when something goes wrong converting a command line string to a type.
0 commit comments