Fix poetenial issues in parser.py#1404
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens up the rosidl_parser/parser.py CLI wrapper used by the Node-side rosidl_parser.js helper by removing unused code and correcting the expected CLI argument count.
Changes:
- Remove an unused
rosidl_parserimport. - Remove an unused intermediate
msg_namevariable. - Update the CLI argument count check to require 3 parameters after the script name (command, package, file path).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rosidl_parser/parser.py
Outdated
| if len(sys.argv) < 4: | ||
| print('Wrong number of argments') |
There was a problem hiding this comment.
The CLI argument count check should likely reject both too-few and too-many arguments. Since this script expects exactly 3 parameters after the script name (command, packageName, filePath), consider checking len(sys.argv) != 4 and printing a usage string so callers can diagnose failures quickly. Also consider printing this error to stderr (like idl_parser.py does), otherwise Node’s execFile error handling may show an empty stderr.
| if len(sys.argv) < 4: | |
| print('Wrong number of argments') | |
| if len(sys.argv) != 4: | |
| print('Usage: {} <command> <packageName> <filePath>'.format(sys.argv[0]), file=sys.stderr) |
rosidl_parser/parser.py
Outdated
| if __name__ == '__main__': | ||
| if len(sys.argv) < 3: | ||
| if len(sys.argv) < 4: | ||
| print('Wrong number of argments') |
There was a problem hiding this comment.
Typo in error message: "argments" should be "arguments".
| print('Wrong number of argments') | |
| print('Wrong number of arguments') |
This PR tightens up the
rosidl_parser/parser.pyCLI wrapper used by the Node-siderosidl_parser.jshelper by removing unused code and correcting the expected CLI argument count.Changes:
rosidl_parserimport.msg_namevariable.Fix: #1403