rsoclean does not work on empty arguments
Jcortesconde opened this issue · comments
Hello, First i"m going to give the short version, and then I will give a more detailed explanation.
python3 introduced a bug in the add_subparsers function, It is an easy fix by changing the arguments of the function like this:
subparsers = parser.add_subparsers(required=True, dest="-h")
For the more detailed explanation:
First the error arises by doing
rosclean
which gives the output
File "/opt/ros/noetic/bin/rosclean", line 35, in <module>
rosclean.rosclean_main()
File "/opt/ros/noetic/lib/python3/dist-packages/rosclean/__init__.py", line 256, in rosclean_main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'
This is a bug that happened in python 3, however is well documented and there is a fix (it doesn`t seem to be top priority on python development)
The only thing to be done is to change the line 248, with this text
subparsers = parser.add_subparsers(required=True, dest="-h")
This change will ouput
usage: rosclean [-h] {check,purge} ...
rosclean: error: the following arguments are required: -h
I don`t know what should be the default argument that should be required, but without the dest parameter set this would be the output
aceback (most recent call last):
File "/opt/ros/noetic/bin/rosclean", line 35, in <module>
rosclean.rosclean_main()
File "/opt/ros/noetic/lib/python3/dist-packages/rosclean/__init__.py", line 255, in rosclean_main
args = parser.parse_args(argv[1:])
File "/usr/lib/python3.8/argparse.py", line 1780, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "/usr/lib/python3.8/argparse.py", line 1812, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/usr/lib/python3.8/argparse.py", line 2047, in _parse_known_args
', '.join(required_actions))
TypeError: sequence item 0: expected str instance, NoneType found
the full documentation on the arguments of add_subparsers.
after the changes I tried all the commands and everything worked fine.
Thanks for the reports. Please see #265 for the proposed fix.
In the future please consider to open a pull request.