@@ -585,7 +585,7 @@ arguments will never be treated as file references.
585585
586586.. versionchanged :: 3.12
587587 :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
589589 ``"strict" ``) to :term: `filesystem encoding and error handler `.
590590 Arguments file should be encoded in UTF-8 instead of ANSI Codepage on Windows.
591591
@@ -1191,7 +1191,7 @@ done downstream after the arguments are parsed.
11911191For example, JSON or YAML conversions have complex error cases that require
11921192better reporting than can be given by the ``type `` keyword. A
11931193: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.
11951195
11961196Even :class: `~argparse.FileType ` has its limitations for use with the ``type ``
11971197keyword. If one argument uses *FileType * and then a subsequent argument fails,
@@ -1445,7 +1445,7 @@ Action classes
14451445Action classes implement the Action API, a callable which returns a callable
14461446which processes arguments from the command-line. Any object which follows
14471447this API may be passed as the ``action `` parameter to
1448- :meth: `add_argument `.
1448+ :meth: `~ArgumentParser. add_argument `.
14491449
14501450.. class :: Action(option_strings, dest, nargs=None, const=None, default=None, \
14511451 type=None, choices=None, required=False, help=None, \
@@ -1723,7 +1723,7 @@ Sub-commands
17231723 :class: `ArgumentParser ` supports the creation of such sub-commands with the
17241724 :meth: `add_subparsers ` method. The :meth: `add_subparsers ` method is normally
17251725 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
17271727 command name and any :class: `ArgumentParser ` constructor arguments, and
17281728 returns an :class: `ArgumentParser ` object that can be modified as usual.
17291729
@@ -1789,7 +1789,7 @@ Sub-commands
17891789 for that particular parser will be printed. The help message will not
17901790 include parent parser or sibling parser messages. (A help message for each
17911791 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.)
17931793
17941794 ::
17951795
@@ -2157,7 +2157,7 @@ the populated namespace and the list of remaining argument strings.
21572157
21582158.. warning ::
21592159 :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
21612161 a prefix of one of its known options, instead of leaving it in the remaining
21622162 arguments list.
21632163
@@ -2295,3 +2295,17 @@ A partial upgrade path from :mod:`optparse` to :mod:`argparse`:
22952295
22962296* Replace the OptionParser constructor ``version `` argument with a call to
22972297 ``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