Author m_khvoinitsky
Recipients m_khvoinitsky
Date 2020-12-02.21:15:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Example which works:

    parser.add_argument('--test', nargs='+', metavar=('TEST', 'TEST2'))

Example which doesn't work:

    parser.add_argument('test', nargs='+', metavar=('TEST', 'TEST2'))

it raises:

    Traceback (most recent call last):
      File <omitted>
        args = parser.parse_args()
      File "/usr/lib/python3.8/", line 1768, in parse_args
        args, argv = self.parse_known_args(args, namespace)
      File "/usr/lib/python3.8/", line 1800, in parse_known_args
        namespace, args = self._parse_known_args(args, namespace)
      File "/usr/lib/python3.8/", line 2006, in _parse_known_args
        start_index = consume_optional(start_index)
      File "/usr/lib/python3.8/", line 1946, in consume_optional
        take_action(action, args, option_string)
      File "/usr/lib/python3.8/", line 1874, in take_action
        action(self, namespace, argument_values, option_string)
      File "/usr/lib/python3.8/", line 1044, in __call__
      File "/usr/lib/python3.8/", line 2494, in print_help
        self._print_message(self.format_help(), file)
      File "/usr/lib/python3.8/", line 2471, in format_help
      File "/usr/lib/python3.8/", line 276, in add_arguments
      File "/usr/lib/python3.8/", line 261, in add_argument
        invocations = [get_invocation(action)]
      File "/usr/lib/python3.8/", line 549, in _format_action_invocation
        metavar, = self._metavar_formatter(action, default)(1)
    ValueError: too many values to unpack (expected 1)

Expected result: help message should look like this:

    usage: test_argparse [-h] TEST [TEST2 ...]

    positional arguments:

    optional arguments:
      -h, --help  show this help message and exit
Date User Action Args
2020-12-02 21:15:50m_khvoinitskysetrecipients: + m_khvoinitsky
2020-12-02 21:15:50m_khvoinitskysetmessageid: <>
2020-12-02 21:15:50m_khvoinitskylinkissue42547 messages
2020-12-02 21:15:50m_khvoinitskycreate