From ab05a2922ae3b1468c64da45db2eb3f0bd8fe15d Mon Sep 17 00:00:00 2001 From: Ryan Friedman Date: Tue, 21 Nov 2023 19:15:13 -0700 Subject: [PATCH] Tools: ros2: Enforce black instead of flake8 * Removed dependency on ament_lint_common * Removed all flake8 artifacts * Ordered linters alphabetically Signed-off-by: Ryan Friedman --- Tools/ros2/ardupilot_dds_tests/.flake8 | 10 ------- Tools/ros2/ardupilot_dds_tests/package.xml | 5 +++- .../ardupilot_dds_tests/test/test_flake8.py | 27 ------------------- Tools/ros2/ardupilot_msgs/CMakeLists.txt | 5 ++++ Tools/ros2/ardupilot_msgs/package.xml | 3 ++- Tools/ros2/ardupilot_sitl/.flake8 | 10 ------- Tools/ros2/ardupilot_sitl/CMakeLists.txt | 3 --- Tools/ros2/ardupilot_sitl/package.xml | 10 +++++-- 8 files changed, 19 insertions(+), 54 deletions(-) delete mode 100644 Tools/ros2/ardupilot_dds_tests/.flake8 delete mode 100644 Tools/ros2/ardupilot_dds_tests/test/test_flake8.py delete mode 100644 Tools/ros2/ardupilot_sitl/.flake8 diff --git a/Tools/ros2/ardupilot_dds_tests/.flake8 b/Tools/ros2/ardupilot_dds_tests/.flake8 deleted file mode 100644 index b79f25fa41199..0000000000000 --- a/Tools/ros2/ardupilot_dds_tests/.flake8 +++ /dev/null @@ -1,10 +0,0 @@ -[flake8] -# Match black line length (default 88). -max-line-length = 88 -# Match black configuration where there are conflicts. -extend-ignore = - # Q000: Double quotes found but single quotes preferred - Q000, - # W503: Line break before binary operator - W503 - diff --git a/Tools/ros2/ardupilot_dds_tests/package.xml b/Tools/ros2/ardupilot_dds_tests/package.xml index 8e21f9ed4bd0c..7b44fbffdcbf9 100644 --- a/Tools/ros2/ardupilot_dds_tests/package.xml +++ b/Tools/ros2/ardupilot_dds_tests/package.xml @@ -17,9 +17,12 @@ rclpy socat + ament_black ament_copyright - ament_flake8 ament_pep257 + ament_uncrustify + ament_xmllint + ament_lint_auto ardupilot_sitl launch launch_pytest diff --git a/Tools/ros2/ardupilot_dds_tests/test/test_flake8.py b/Tools/ros2/ardupilot_dds_tests/test/test_flake8.py deleted file mode 100644 index 17771247a5472..0000000000000 --- a/Tools/ros2/ardupilot_dds_tests/test/test_flake8.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2017 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Test Python files satisfy the flake8 linter requirements.""" -from ament_flake8.main import main_with_errors -import pytest - - -@pytest.mark.flake8 -@pytest.mark.linter -def test_flake8(): - """flake8 test case.""" - rc, errors = main_with_errors(argv=[]) - assert rc == 0, "Found %d code style errors / warnings:\n" % len( - errors - ) + "\n".join(errors) diff --git a/Tools/ros2/ardupilot_msgs/CMakeLists.txt b/Tools/ros2/ardupilot_msgs/CMakeLists.txt index 5a56bd31cc357..8096431370687 100644 --- a/Tools/ros2/ardupilot_msgs/CMakeLists.txt +++ b/Tools/ros2/ardupilot_msgs/CMakeLists.txt @@ -18,6 +18,11 @@ rosidl_generate_interfaces(${PROJECT_NAME} ament_export_dependencies(rosidl_default_runtime) +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + # --------------------------------------------------------------------------- # # Call last. diff --git a/Tools/ros2/ardupilot_msgs/package.xml b/Tools/ros2/ardupilot_msgs/package.xml index b2286616eb698..08e92bf1df7d9 100644 --- a/Tools/ros2/ardupilot_msgs/package.xml +++ b/Tools/ros2/ardupilot_msgs/package.xml @@ -13,8 +13,9 @@ rosidl_default_runtime + ament_cmake_copyright + ament_cmake_xmllint ament_lint_auto - ament_lint_common rosidl_interface_packages diff --git a/Tools/ros2/ardupilot_sitl/.flake8 b/Tools/ros2/ardupilot_sitl/.flake8 deleted file mode 100644 index b79f25fa41199..0000000000000 --- a/Tools/ros2/ardupilot_sitl/.flake8 +++ /dev/null @@ -1,10 +0,0 @@ -[flake8] -# Match black line length (default 88). -max-line-length = 88 -# Match black configuration where there are conflicts. -extend-ignore = - # Q000: Double quotes found but single quotes preferred - Q000, - # W503: Line break before binary operator - W503 - diff --git a/Tools/ros2/ardupilot_sitl/CMakeLists.txt b/Tools/ros2/ardupilot_sitl/CMakeLists.txt index 9d40ea746d43b..4b50d602da341 100644 --- a/Tools/ros2/ardupilot_sitl/CMakeLists.txt +++ b/Tools/ros2/ardupilot_sitl/CMakeLists.txt @@ -88,9 +88,6 @@ ament_python_install_package(${PROJECT_NAME} # build tests if(BUILD_TESTING) - # Override default flake8 configuration. - set(ament_cmake_flake8_CONFIG_FILE ${CMAKE_SOURCE_DIR}/.flake8) - # Add linters. find_package(ament_lint_auto REQUIRED) ament_lint_auto_find_test_dependencies() diff --git a/Tools/ros2/ardupilot_sitl/package.xml b/Tools/ros2/ardupilot_sitl/package.xml index 2c3a375695013..d0851a191e3a1 100644 --- a/Tools/ros2/ardupilot_sitl/package.xml +++ b/Tools/ros2/ardupilot_sitl/package.xml @@ -13,9 +13,15 @@ micro_ros_agent - ament_cmake_pytest ament_lint_auto - ament_lint_common + ament_cmake_black + ament_cmake_copyright + ament_cmake_lint_cmake + ament_cmake_pep257 + ament_cmake_pytest + ament_cmake_uncrustify + ament_cmake_xmllint + ament_cmake