From e0d3f6e8ea74ff3e2a1d6eaae6b05086c8ec5d81 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Thu, 3 Oct 2024 22:11:35 -0400 Subject: [PATCH] use ament_cmake_mypy instead Signed-off-by: Michael Carlstrom --- rosidl_adapter/CMakeLists.txt | 1 + rosidl_adapter/package.xml | 2 +- rosidl_adapter/rosidl_adapter/parser.py | 2 +- rosidl_adapter/test/test_mypy.py | 23 ----------------------- 4 files changed, 3 insertions(+), 25 deletions(-) delete mode 100644 rosidl_adapter/test/test_mypy.py diff --git a/rosidl_adapter/CMakeLists.txt b/rosidl_adapter/CMakeLists.txt index 33d9e879a..ae1337a91 100644 --- a/rosidl_adapter/CMakeLists.txt +++ b/rosidl_adapter/CMakeLists.txt @@ -10,6 +10,7 @@ ament_python_install_package(${PROJECT_NAME}) if(BUILD_TESTING) find_package(ament_cmake_pytest REQUIRED) find_package(ament_lint_auto REQUIRED) + find_package(ament_cmake_mypy REQUIRED) ament_lint_auto_find_test_dependencies() ament_add_pytest_test(pytest test) endif() diff --git a/rosidl_adapter/package.xml b/rosidl_adapter/package.xml index 8c6c21d8c..a34cf27d9 100644 --- a/rosidl_adapter/package.xml +++ b/rosidl_adapter/package.xml @@ -26,10 +26,10 @@ python3-empy rosidl_cli + ament_cmake_mypy ament_cmake_pytest ament_lint_common ament_lint_auto - ament_mypy ament_cmake diff --git a/rosidl_adapter/rosidl_adapter/parser.py b/rosidl_adapter/rosidl_adapter/parser.py index c6ae74ad3..aeee4b933 100644 --- a/rosidl_adapter/rosidl_adapter/parser.py +++ b/rosidl_adapter/rosidl_adapter/parser.py @@ -817,7 +817,7 @@ def validate_field_types(spec: Union[MessageSpecification, known_msg_types: List[BaseType]) -> None: if isinstance(spec, MessageSpecification): spec_type = 'Message' - fields = spec.fields + fields: List[Field] = spec.fields elif isinstance(spec, ServiceSpecification): spec_type = 'Service' fields = spec.request.fields + spec.response.fields diff --git a/rosidl_adapter/test/test_mypy.py b/rosidl_adapter/test/test_mypy.py deleted file mode 100644 index 97e4f502a..000000000 --- a/rosidl_adapter/test/test_mypy.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2024 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. - -from ament_mypy.main import main -import pytest - - -@pytest.mark.mypy -@pytest.mark.linter -def test_mypy() -> None: - rc = main(argv=[]) - assert rc == 0, 'Found type errors!'