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 <ryanfriedman5410+github@gmail.com>
This commit is contained in:
Ryan Friedman 2023-11-21 19:15:13 -07:00 committed by Tom Pittenger
parent d4c7601b1b
commit 61e2c5fda1
8 changed files with 19 additions and 54 deletions

View File

@ -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

View File

@ -17,9 +17,12 @@
<exec_depend>rclpy</exec_depend>
<exec_depend>socat</exec_depend>
<test_depend>ament_black</test_depend>
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>ament_uncrustify</test_depend>
<test_depend>ament_xmllint</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ardupilot_sitl</test_depend>
<test_depend>launch</test_depend>
<test_depend>launch_pytest</test_depend>

View File

@ -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)

View File

@ -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.

View File

@ -13,8 +13,9 @@
<exec_depend>rosidl_default_runtime</exec_depend>
<test_depend>ament_cmake_copyright</test_depend>
<test_depend>ament_cmake_xmllint</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<member_of_group>rosidl_interface_packages</member_of_group>

View File

@ -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

View File

@ -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()

View File

@ -13,9 +13,15 @@
<exec_depend>micro_ros_agent</exec_depend>
<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_cmake_black</test_depend>
<test_depend>ament_cmake_copyright</test_depend>
<test_depend>ament_cmake_lint_cmake</test_depend>
<test_depend>ament_cmake_pep257</test_depend>
<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_cmake_uncrustify</test_depend>
<test_depend>ament_cmake_xmllint</test_depend>
<export>
<build_type>ament_cmake</build_type>