Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure subparser is required #683

Merged
merged 1 commit into from
Aug 5, 2022

Conversation

ijnek
Copy link
Member

@ijnek ijnek commented Aug 5, 2022

When bloom-generate is called without arguments, this now shows:

usage: bloom-generate [-h] [debian | rosdebian | rosrpm | rpm] ...
bloom-generate: error: the following arguments are required: [debian | rosdebian | rosrpm | rpm]

Rather than continuing without an argument and causing an unrelated error:

/home/russ/.local/lib/python3.10/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning:  is an invalid version and will not be supported in a future release
  warnings.warn(
/home/russ/.local/lib/python3.10/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning:  is an invalid version and will not be supported in a future release
  warnings.warn(
Traceback (most recent call last):
  File "/usr/bin/bloom-generate", line 33, in <module>
    sys.exit(load_entry_point('bloom==0.10.7', 'console_scripts', 'bloom-generate')())
  File "/usr/lib/python3/dist-packages/bloom/commands/generate.py", line 85, in main
    handle_global_arguments(args)
  File "/usr/lib/python3/dist-packages/bloom/util.py", line 308, in handle_global_arguments
    enable_debug(args.debug or 'DEBUG' in os.environ)
AttributeError: 'Namespace' object has no attribute 'debug'

This fixes the issue #665 is trying to solve.

Signed-off-by: Kenji Brameld <[email protected]>
@cottsay cottsay merged commit 35af61f into ros-infrastructure:master Aug 5, 2022
@ijnek ijnek deleted the ijnek-subparser-required branch August 5, 2022 23:02
@christianrauch
Copy link
Contributor

This breaks bloom on RHEL 8 and clones:

  File "/usr/lib64/python3.6/argparse.py", line 1707, in add_subparsers
    action = parsers_class(option_strings=[], **kwargs)
TypeError: __init__() got an unexpected keyword argument 'required'

@ijnek
Copy link
Member Author

ijnek commented Apr 6, 2023

Thanks for the report @christianrauch, I can confirm that the required argument was added in Python3.7

required - Whether or not a subcommand must be provided, by default False (added in 3.7) https://docs.python.org/3.7/library/argparse.html#argparse.ArgumentParser.add_subparsers

I have put together a fix: #700

@cottsay
Copy link
Member

cottsay commented Apr 6, 2023

This shouldn't have made it through CI builds if it doesn't work with Python 3.6. We should also investigate that.

@ijnek
Copy link
Member Author

ijnek commented Apr 9, 2023

I'm not sure which tests were meant to pick up on the problem, but I have confirmed this fixes the immediate problem on RHEL8 in a container. I'd be happy to add a smoke test if there are none for bloom/commands/generate.py yet.

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.

3 participants