redhat-openstack / infrared

Plugin based framework that aims to provide an easy-to-use CLI for Ansible based projects
https://infrared.readthedocs.io/en/latest/index.html
Apache License 2.0
100 stars 95 forks source link

infrared fails on python3.11 #416

Open gthiemonge opened 2 years ago

gthiemonge commented 2 years ago

When using infrared with python3.11 (from fedora), I get the following backtrace:

/usr/lib/python3.11/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
Traceback (most recent call last):
  File "/home/gthiemon/.local/bin/ir", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/gthiemon/.local/lib/python3.11/site-packages/infrared/main.py", line 527, in main
    specs_manager.register_spec(
  File "/home/gthiemon/.local/lib/python3.11/site-packages/infrared/api.py", line 196, in register_spec
    spec_object.extend_cli(self.root_subparsers)
  File "/home/gthiemon/.local/lib/python3.11/site-packages/infrared/main.py", line 342, in extend_cli
    import_parser = plugin_subparsers.add_parser(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/argparse.py", line 1185, in add_parser
    raise ArgumentError(self, _('conflicting subparser: %s') % name)
argparse.ArgumentError: argument command0: conflicting subparser: import

It appears that the import command is added twice in the parser: https://github.com/redhat-openstack/infrared/blob/master/infrared/main.py#L337-L345

tosky commented 1 year ago

https://review.gerrithub.io/c/redhat-openstack/infrared/+/548499