Skip to content

Fix argparse help output broken by bb1e7a8617#48

Merged
jplexer merged 1 commit intocoredevices:mainfrom
howeaj:main
Apr 10, 2026
Merged

Fix argparse help output broken by bb1e7a8617#48
jplexer merged 1 commit intocoredevices:mainfrom
howeaj:main

Conversation

@howeaj
Copy link
Copy Markdown

@howeaj howeaj commented Apr 7, 2026

Fixes the crashes that prevent help from ever being generated for emu commands. For example:

> pebble emu-button
Traceback (most recent call last):
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 1965, in _parse_known_args2
    namespace, args = self._parse_known_args(args, namespace, intermixed)
                      ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 2262, in _parse_known_args
    raise ArgumentError(None, _('the following arguments are required: %s') %
               ', '.join(required_actions))
argparse.ArgumentError: the following arguments are required: action

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ajh/.local/bin/pebble", line 10, in <module>
    sys.exit(run_tool())
             ~~~~~~~~^^
  File "/home/ajh/.local/share/uv/tools/pebble-tool/lib/python3.13/site-packages/pebble_tool/__init__.py", line 54, in run_tool
    args = parser.parse_args(args)
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 1926, in parse_args
    args, argv = self.parse_known_args(args, namespace)
                 ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 1936, in parse_known_args
    return self._parse_known_args2(args, namespace, intermixed=False)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 1965, in _parse_known_args2
    namespace, args = self._parse_known_args(args, namespace, intermixed)
                      ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 2220, in _parse_known_args
    stop_index = consume_positionals(start_index)
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 2172, in consume_positionals
    take_action(action, args)
    ~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 2041, in take_action
    action(self, namespace, argument_values, option_string)
    ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 1286, in __call__
    subnamespace, arg_strings = subparser.parse_known_args(arg_strings, None)
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 1936, in parse_known_args
    return self._parse_known_args2(args, namespace, intermixed=False)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 1967, in _parse_known_args2
    self.error(str(err))
    ~~~~~~~~~~^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 2684, in error
    self.print_usage(_sys.stderr)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 2651, in print_usage
    self._print_message(self.format_usage(), file)
                        ~~~~~~~~~~~~~~~~~^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 2616, in format_usage
    return formatter.format_help()
           ~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 287, in format_help
    help = self._root_section.format_help()
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 216, in format_help
    item_help = join([func(*args) for func, args in self.items])
                      ~~~~^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 325, in _format_usage
    action_usage = format(optionals + positionals, groups)
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 393, in _format_actions_usage
    return ' '.join(self._get_actions_usage_parts(actions, groups))
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 396, in _get_actions_usage_parts
    parts, _ = self._get_actions_usage_parts_with_split(actions, groups)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/ajh/.local/share/uv/python/cpython-3.13.12-linux-x86_64-gnu/lib/python3.13/argparse.py", line 412, in _get_actions_usage_parts_with_split
    raise ValueError(f'empty group {group}')
ValueError: empty group <argparse._MutuallyExclusiveGroup object at 0x70247493b850>

@ericmigi ericmigi requested a review from jplexer April 7, 2026 14:33
@jplexer jplexer merged commit ec6b03b into coredevices:main Apr 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants