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

Added more ruff rules #59

Merged
merged 6 commits into from
Jan 26, 2024
Merged

Added more ruff rules #59

merged 6 commits into from
Jan 26, 2024

Conversation

amessing-bdai
Copy link
Collaborator

@amessing-bdai amessing-bdai commented Jan 26, 2024

I've added more rules to ruff based on the ones we are adding to other repos.

@mhidalgo-bdai Some of these involve rules for the docstring. Can you make sure that I've not misrepresented anything?

@amessing-bdai
Copy link
Collaborator Author

amessing-bdai commented Jan 26, 2024

@mhidalgo-bdai

Starting >>> proto2ros_tests
--- stderr: proto2ros_tests
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/cli/generate.py", line 181, in <module>
    sys.exit(main())
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/cli/generate.py", line 177, in main
    return do_generate(args)
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/cli/generate.py", line 54, in do_generate
    equivalences.extend(extract_equivalences(source_descriptor, config))
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/equivalences.py", line 507, in extract_equivalences_from_source
    yield from extract_equivalences_from_message(message_type, source_descriptor, message_location, config)
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/equivalences.py", line 479, in extract_equivalences_from_message
    yield compute_equivalence_for_message(message_descriptor, source_descriptor, location, config)
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/equivalences.py", line 400, in compute_equivalence_for_message
    oneof_message_spec.annotations["tagged"] = list(zip(oneof_constants[1:], oneof_fields[:-1], strict=True))
ValueError: zip() argument 2 is longer than argument 1
CMake Error at /__w/ros_utilities/ros_utilities/install/proto2ros/share/proto2ros/cmake/proto2ros_generate.cmake:116 (execute_process):
  execute_process failed command indexes:

    1: "Child return code: 1"

Call Stack (most recent call first):
  CMakeLists.txt:15 (proto2ros_generate)


---
Failed   <<< proto2ros_tests [1.[49](https://github.com/bdaiinstitute/ros_utilities/actions/runs/7671617303/job/20910420019?pr=59#step:4:50)s, exited with code 1]

One of the rules added requires setting the strict parameter of zip to True. This gives a free-length check. Currently, we get the above that the sequences are not of the same length.

Copy link
Contributor

@mhidalgo-bdai mhidalgo-bdai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there. Left a few minor comments.

bdai_ros2_wrappers/bdai_ros2_wrappers/scope.py Outdated Show resolved Hide resolved
proto2ros/proto2ros/equivalences.py Outdated Show resolved Hide resolved
@amessing-bdai
Copy link
Collaborator Author

@mhidalgo-bdai

Starting >>> proto2ros_tests
--- stderr: proto2ros_tests
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/cli/generate.py", line 181, in <module>
    sys.exit(main())
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/cli/generate.py", line 177, in main
    return do_generate(args)
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/cli/generate.py", line 58, in do_generate
    fix_dependency_cycles(message_specifications, quiet=args.dry)
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/dependencies.py", line 48, in fix_dependency_cycles
    for parent, child in pairwise(cycle):
ValueError: zip() argument 2 is shorter than argument 1
CMake Error at /__w/ros_utilities/ros_utilities/install/proto2ros/share/proto2ros/cmake/proto2ros_generate.cmake:116 (execute_process):
  execute_process failed command indexes:

    1: "Child return code: 1"

Call Stack (most recent call first):
  CMakeLists.txt:15 (proto2ros_generate)


---
Failed   <<< proto2ros_tests [1.55s, exited with code 1]

One more zip issue.

@amessing-bdai
Copy link
Collaborator Author

@mhidalgo-bdai

Starting >>> proto2ros_tests
--- stderr: proto2ros_tests
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/cli/generate.py", line 181, in <module>
    sys.exit(main())
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/cli/generate.py", line 177, in main
    return do_generate(args)
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/cli/generate.py", line 58, in do_generate
    fix_dependency_cycles(message_specifications, quiet=args.dry)
  File "/__w/ros_utilities/ros_utilities/install/proto2ros/local/lib/python3.10/dist-packages/proto2ros/dependencies.py", line 48, in fix_dependency_cycles
    for parent, child in pairwise(cycle):
ValueError: zip() argument 2 is shorter than argument 1
CMake Error at /__w/ros_utilities/ros_utilities/install/proto2ros/share/proto2ros/cmake/proto2ros_generate.cmake:116 (execute_process):
  execute_process failed command indexes:

    1: "Child return code: 1"

Call Stack (most recent call first):
  CMakeLists.txt:15 (proto2ros_generate)


---
Failed   <<< proto2ros_tests [1.55s, exited with code 1]

One more zip issue.

I think this is one where we need to ignore the ruff rule because we cannot index the iterable.

@amessing-bdai amessing-bdai merged commit 9fe8e88 into main Jan 26, 2024
3 checks passed
@amessing-bdai amessing-bdai deleted the amessing/more_ruff_rules branch January 26, 2024 21:42
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