From 99032ab8d26cc01ef2ba37196a3648fb03e688af Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Thu, 3 Oct 2024 14:57:56 +0000 Subject: [PATCH 1/4] Changelog. Signed-off-by: Chris Lalancette --- rosidl_adapter/CHANGELOG.rst | 5 +++++ rosidl_cli/CHANGELOG.rst | 3 +++ rosidl_cmake/CHANGELOG.rst | 3 +++ rosidl_generator_c/CHANGELOG.rst | 5 +++++ rosidl_generator_cpp/CHANGELOG.rst | 5 +++++ rosidl_generator_tests/CHANGELOG.rst | 3 +++ rosidl_generator_type_description/CHANGELOG.rst | 3 +++ rosidl_parser/CHANGELOG.rst | 3 +++ rosidl_pycommon/CHANGELOG.rst | 6 ++++++ rosidl_runtime_c/CHANGELOG.rst | 3 +++ rosidl_runtime_cpp/CHANGELOG.rst | 3 +++ rosidl_typesupport_interface/CHANGELOG.rst | 3 +++ rosidl_typesupport_introspection_c/CHANGELOG.rst | 5 +++++ rosidl_typesupport_introspection_cpp/CHANGELOG.rst | 5 +++++ rosidl_typesupport_introspection_tests/CHANGELOG.rst | 3 +++ 15 files changed, 58 insertions(+) diff --git a/rosidl_adapter/CHANGELOG.rst b/rosidl_adapter/CHANGELOG.rst index c10d6c5d5..78d8efe4e 100644 --- a/rosidl_adapter/CHANGELOG.rst +++ b/rosidl_adapter/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog for package rosidl_adapter ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- +* Support empy3 and empy4 (`#821 `_) +* Contributors: Alejandro Hernández Cordero + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_cli/CHANGELOG.rst b/rosidl_cli/CHANGELOG.rst index 615afe4b5..ee60d9348 100644 --- a/rosidl_cli/CHANGELOG.rst +++ b/rosidl_cli/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package rosidl_cli ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_cmake/CHANGELOG.rst b/rosidl_cmake/CHANGELOG.rst index 34ee935fc..6b037058d 100644 --- a/rosidl_cmake/CHANGELOG.rst +++ b/rosidl_cmake/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package rosidl_cmake ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_generator_c/CHANGELOG.rst b/rosidl_generator_c/CHANGELOG.rst index 40bee3694..fda7ceb96 100644 --- a/rosidl_generator_c/CHANGELOG.rst +++ b/rosidl_generator_c/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog for package rosidl_generator_c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- +* Add types `rosidl_pycommon` (`#824 `_) +* Contributors: Michael Carlstrom + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_generator_cpp/CHANGELOG.rst b/rosidl_generator_cpp/CHANGELOG.rst index c681c6b26..2eceef52f 100644 --- a/rosidl_generator_cpp/CHANGELOG.rst +++ b/rosidl_generator_cpp/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog for package rosidl_generator_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- +* Add types `rosidl_pycommon` (`#824 `_) +* Contributors: Michael Carlstrom + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_generator_tests/CHANGELOG.rst b/rosidl_generator_tests/CHANGELOG.rst index 7da557061..1dbb6593c 100644 --- a/rosidl_generator_tests/CHANGELOG.rst +++ b/rosidl_generator_tests/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package rosidl_generator_tests ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 4.8.1 (2024-06-25) ------------------ * Silence one more gcc false-positive. (`#814 `_) diff --git a/rosidl_generator_type_description/CHANGELOG.rst b/rosidl_generator_type_description/CHANGELOG.rst index 6d7b2281b..8c62711a7 100644 --- a/rosidl_generator_type_description/CHANGELOG.rst +++ b/rosidl_generator_type_description/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package rosidl_generator_type_description ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_parser/CHANGELOG.rst b/rosidl_parser/CHANGELOG.rst index 9a8b9ddb5..05f5841ce 100644 --- a/rosidl_parser/CHANGELOG.rst +++ b/rosidl_parser/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package rosidl_parser ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_pycommon/CHANGELOG.rst b/rosidl_pycommon/CHANGELOG.rst index 73b43be89..6ea088c16 100644 --- a/rosidl_pycommon/CHANGELOG.rst +++ b/rosidl_pycommon/CHANGELOG.rst @@ -2,6 +2,12 @@ Changelog for package rosidl_pycommon ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- +* Add types `rosidl_pycommon` (`#824 `_) +* Support empy3 and empy4 (`#821 `_) +* Contributors: Alejandro Hernández Cordero, Michael Carlstrom + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_runtime_c/CHANGELOG.rst b/rosidl_runtime_c/CHANGELOG.rst index 4df7cb7de..10a60e0cd 100644 --- a/rosidl_runtime_c/CHANGELOG.rst +++ b/rosidl_runtime_c/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package rosidl_runtime_c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_runtime_cpp/CHANGELOG.rst b/rosidl_runtime_cpp/CHANGELOG.rst index 3d39ce7c2..f0b55bca6 100644 --- a/rosidl_runtime_cpp/CHANGELOG.rst +++ b/rosidl_runtime_cpp/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package rosidl_runtime_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_typesupport_interface/CHANGELOG.rst b/rosidl_typesupport_interface/CHANGELOG.rst index be0a79f07..0fd6ba8f4 100644 --- a/rosidl_typesupport_interface/CHANGELOG.rst +++ b/rosidl_typesupport_interface/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package rosidl_typesupport_interface ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_typesupport_introspection_c/CHANGELOG.rst b/rosidl_typesupport_introspection_c/CHANGELOG.rst index 64e922eda..6fd1cde50 100644 --- a/rosidl_typesupport_introspection_c/CHANGELOG.rst +++ b/rosidl_typesupport_introspection_c/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog for package rosidl_typesupport_introspection_c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- +* Add types `rosidl_pycommon` (`#824 `_) +* Contributors: Michael Carlstrom + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_typesupport_introspection_cpp/CHANGELOG.rst b/rosidl_typesupport_introspection_cpp/CHANGELOG.rst index 65b070472..ef673e037 100644 --- a/rosidl_typesupport_introspection_cpp/CHANGELOG.rst +++ b/rosidl_typesupport_introspection_cpp/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog for package rosidl_typesupport_introspection_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- +* Add types `rosidl_pycommon` (`#824 `_) +* Contributors: Michael Carlstrom + 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_typesupport_introspection_tests/CHANGELOG.rst b/rosidl_typesupport_introspection_tests/CHANGELOG.rst index d74bc9286..63baae4e1 100644 --- a/rosidl_typesupport_introspection_tests/CHANGELOG.rst +++ b/rosidl_typesupport_introspection_tests/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package rosidl_typesupport_introspection_tests ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 4.8.1 (2024-06-25) ------------------ From da9b4a4c32272df34dd8449a45ebd652a7c129e5 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Thu, 3 Oct 2024 14:58:05 +0000 Subject: [PATCH 2/4] 4.9.0 --- rosidl_adapter/CHANGELOG.rst | 4 ++-- rosidl_adapter/package.xml | 2 +- rosidl_cli/CHANGELOG.rst | 4 ++-- rosidl_cli/package.xml | 2 +- rosidl_cli/setup.py | 2 +- rosidl_cmake/CHANGELOG.rst | 4 ++-- rosidl_cmake/package.xml | 2 +- rosidl_generator_c/CHANGELOG.rst | 4 ++-- rosidl_generator_c/package.xml | 2 +- rosidl_generator_cpp/CHANGELOG.rst | 4 ++-- rosidl_generator_cpp/package.xml | 2 +- rosidl_generator_tests/CHANGELOG.rst | 4 ++-- rosidl_generator_tests/package.xml | 2 +- rosidl_generator_type_description/CHANGELOG.rst | 4 ++-- rosidl_generator_type_description/package.xml | 2 +- rosidl_parser/CHANGELOG.rst | 4 ++-- rosidl_parser/package.xml | 2 +- rosidl_pycommon/CHANGELOG.rst | 4 ++-- rosidl_pycommon/package.xml | 2 +- rosidl_pycommon/setup.py | 2 +- rosidl_runtime_c/CHANGELOG.rst | 4 ++-- rosidl_runtime_c/package.xml | 2 +- rosidl_runtime_cpp/CHANGELOG.rst | 4 ++-- rosidl_runtime_cpp/package.xml | 2 +- rosidl_typesupport_interface/CHANGELOG.rst | 4 ++-- rosidl_typesupport_interface/package.xml | 2 +- rosidl_typesupport_introspection_c/CHANGELOG.rst | 4 ++-- rosidl_typesupport_introspection_c/package.xml | 2 +- rosidl_typesupport_introspection_cpp/CHANGELOG.rst | 4 ++-- rosidl_typesupport_introspection_cpp/package.xml | 2 +- rosidl_typesupport_introspection_tests/CHANGELOG.rst | 4 ++-- rosidl_typesupport_introspection_tests/package.xml | 2 +- 32 files changed, 47 insertions(+), 47 deletions(-) diff --git a/rosidl_adapter/CHANGELOG.rst b/rosidl_adapter/CHANGELOG.rst index 78d8efe4e..bf601ba07 100644 --- a/rosidl_adapter/CHANGELOG.rst +++ b/rosidl_adapter/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_adapter ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ * Support empy3 and empy4 (`#821 `_) * Contributors: Alejandro Hernández Cordero diff --git a/rosidl_adapter/package.xml b/rosidl_adapter/package.xml index b94409496..192c883f1 100644 --- a/rosidl_adapter/package.xml +++ b/rosidl_adapter/package.xml @@ -2,7 +2,7 @@ rosidl_adapter - 4.8.1 + 4.9.0 API and scripts to parse .msg/.srv/.action files and convert them to .idl. diff --git a/rosidl_cli/CHANGELOG.rst b/rosidl_cli/CHANGELOG.rst index ee60d9348..13beffa81 100644 --- a/rosidl_cli/CHANGELOG.rst +++ b/rosidl_cli/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_cli ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_cli/package.xml b/rosidl_cli/package.xml index 591e702f3..46f5c7ee5 100644 --- a/rosidl_cli/package.xml +++ b/rosidl_cli/package.xml @@ -2,7 +2,7 @@ rosidl_cli - 4.8.1 + 4.9.0 Command line tools for ROS interface generation. diff --git a/rosidl_cli/setup.py b/rosidl_cli/setup.py index fddf6e2b4..0f3c15ee5 100644 --- a/rosidl_cli/setup.py +++ b/rosidl_cli/setup.py @@ -3,7 +3,7 @@ setup( name='rosidl_cli', - version='4.8.1', + version='4.9.0', packages=find_packages(exclude=['test']), extras_require={ 'completion': ['argcomplete'], diff --git a/rosidl_cmake/CHANGELOG.rst b/rosidl_cmake/CHANGELOG.rst index 6b037058d..c413471f6 100644 --- a/rosidl_cmake/CHANGELOG.rst +++ b/rosidl_cmake/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_cmake ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_cmake/package.xml b/rosidl_cmake/package.xml index bcff069f5..bb222cbcf 100644 --- a/rosidl_cmake/package.xml +++ b/rosidl_cmake/package.xml @@ -2,7 +2,7 @@ rosidl_cmake - 4.8.1 + 4.9.0 The CMake functionality to invoke code generation for ROS interface files. Aditya Pande diff --git a/rosidl_generator_c/CHANGELOG.rst b/rosidl_generator_c/CHANGELOG.rst index fda7ceb96..9c6e63e48 100644 --- a/rosidl_generator_c/CHANGELOG.rst +++ b/rosidl_generator_c/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_generator_c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ * Add types `rosidl_pycommon` (`#824 `_) * Contributors: Michael Carlstrom diff --git a/rosidl_generator_c/package.xml b/rosidl_generator_c/package.xml index d1efb9680..a29de014a 100644 --- a/rosidl_generator_c/package.xml +++ b/rosidl_generator_c/package.xml @@ -2,7 +2,7 @@ rosidl_generator_c - 4.8.1 + 4.9.0 Generate the ROS interfaces in C. Aditya Pande diff --git a/rosidl_generator_cpp/CHANGELOG.rst b/rosidl_generator_cpp/CHANGELOG.rst index 2eceef52f..55c07c76c 100644 --- a/rosidl_generator_cpp/CHANGELOG.rst +++ b/rosidl_generator_cpp/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_generator_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ * Add types `rosidl_pycommon` (`#824 `_) * Contributors: Michael Carlstrom diff --git a/rosidl_generator_cpp/package.xml b/rosidl_generator_cpp/package.xml index cbeefc445..5f3f3f49a 100644 --- a/rosidl_generator_cpp/package.xml +++ b/rosidl_generator_cpp/package.xml @@ -2,7 +2,7 @@ rosidl_generator_cpp - 4.8.1 + 4.9.0 Generate the ROS interfaces in C++. Aditya Pande diff --git a/rosidl_generator_tests/CHANGELOG.rst b/rosidl_generator_tests/CHANGELOG.rst index 1dbb6593c..632050755 100644 --- a/rosidl_generator_tests/CHANGELOG.rst +++ b/rosidl_generator_tests/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_generator_tests ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_generator_tests/package.xml b/rosidl_generator_tests/package.xml index af1275e7a..36a16ef16 100644 --- a/rosidl_generator_tests/package.xml +++ b/rosidl_generator_tests/package.xml @@ -2,7 +2,7 @@ rosidl_generator_tests - 4.8.1 + 4.9.0 Integration tests for rosidl_generator_c and rosidl_generator_cpp packages. Aditya Pande diff --git a/rosidl_generator_type_description/CHANGELOG.rst b/rosidl_generator_type_description/CHANGELOG.rst index 8c62711a7..f984b5bf6 100644 --- a/rosidl_generator_type_description/CHANGELOG.rst +++ b/rosidl_generator_type_description/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_generator_type_description ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_generator_type_description/package.xml b/rosidl_generator_type_description/package.xml index fb9011e4f..c6fad9117 100644 --- a/rosidl_generator_type_description/package.xml +++ b/rosidl_generator_type_description/package.xml @@ -2,7 +2,7 @@ rosidl_generator_type_description - 4.8.1 + 4.9.0 Generate hashes and descriptions of ROS 2 interface types, per REP-2011. Emerson Knapp diff --git a/rosidl_parser/CHANGELOG.rst b/rosidl_parser/CHANGELOG.rst index 05f5841ce..75d86cd20 100644 --- a/rosidl_parser/CHANGELOG.rst +++ b/rosidl_parser/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_parser ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_parser/package.xml b/rosidl_parser/package.xml index 7e58fa970..68222fa91 100644 --- a/rosidl_parser/package.xml +++ b/rosidl_parser/package.xml @@ -2,7 +2,7 @@ rosidl_parser - 4.8.1 + 4.9.0 The parser for `.idl` ROS interface files. Aditya Pande diff --git a/rosidl_pycommon/CHANGELOG.rst b/rosidl_pycommon/CHANGELOG.rst index 6ea088c16..9faf54705 100644 --- a/rosidl_pycommon/CHANGELOG.rst +++ b/rosidl_pycommon/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_pycommon ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ * Add types `rosidl_pycommon` (`#824 `_) * Support empy3 and empy4 (`#821 `_) * Contributors: Alejandro Hernández Cordero, Michael Carlstrom diff --git a/rosidl_pycommon/package.xml b/rosidl_pycommon/package.xml index 30a49c26b..d63cb3751 100644 --- a/rosidl_pycommon/package.xml +++ b/rosidl_pycommon/package.xml @@ -2,7 +2,7 @@ rosidl_pycommon - 4.8.1 + 4.9.0 Common Python functions used by rosidl packages. Aditya Pande diff --git a/rosidl_pycommon/setup.py b/rosidl_pycommon/setup.py index 497736123..b642322ab 100644 --- a/rosidl_pycommon/setup.py +++ b/rosidl_pycommon/setup.py @@ -5,7 +5,7 @@ setup( name=package_name, - version='4.8.1', + version='4.9.0', packages=find_packages(exclude=['test']), data_files=[ ('share/ament_index/resource_index/packages', diff --git a/rosidl_runtime_c/CHANGELOG.rst b/rosidl_runtime_c/CHANGELOG.rst index 10a60e0cd..a45a05145 100644 --- a/rosidl_runtime_c/CHANGELOG.rst +++ b/rosidl_runtime_c/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_runtime_c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_runtime_c/package.xml b/rosidl_runtime_c/package.xml index 5e98e7cb7..13c82fa7b 100644 --- a/rosidl_runtime_c/package.xml +++ b/rosidl_runtime_c/package.xml @@ -2,7 +2,7 @@ rosidl_runtime_c - 4.8.1 + 4.9.0 Provides definitions, initialization and finalization functions, and macros for getting and working with rosidl typesupport types in C. Aditya Pande diff --git a/rosidl_runtime_cpp/CHANGELOG.rst b/rosidl_runtime_cpp/CHANGELOG.rst index f0b55bca6..14a92f60b 100644 --- a/rosidl_runtime_cpp/CHANGELOG.rst +++ b/rosidl_runtime_cpp/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_runtime_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_runtime_cpp/package.xml b/rosidl_runtime_cpp/package.xml index 9ffec3c73..9621116c9 100644 --- a/rosidl_runtime_cpp/package.xml +++ b/rosidl_runtime_cpp/package.xml @@ -2,7 +2,7 @@ rosidl_runtime_cpp - 4.8.1 + 4.9.0 Provides definitions and templated functions for getting and working with rosidl typesupport types in C++. Aditya Pande diff --git a/rosidl_typesupport_interface/CHANGELOG.rst b/rosidl_typesupport_interface/CHANGELOG.rst index 0fd6ba8f4..28cd0b5b7 100644 --- a/rosidl_typesupport_interface/CHANGELOG.rst +++ b/rosidl_typesupport_interface/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_typesupport_interface ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_typesupport_interface/package.xml b/rosidl_typesupport_interface/package.xml index 0688a1dd3..bf81df4f2 100644 --- a/rosidl_typesupport_interface/package.xml +++ b/rosidl_typesupport_interface/package.xml @@ -2,7 +2,7 @@ rosidl_typesupport_interface - 4.8.1 + 4.9.0 The interface for rosidl typesupport packages. diff --git a/rosidl_typesupport_introspection_c/CHANGELOG.rst b/rosidl_typesupport_introspection_c/CHANGELOG.rst index 6fd1cde50..7dd269693 100644 --- a/rosidl_typesupport_introspection_c/CHANGELOG.rst +++ b/rosidl_typesupport_introspection_c/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_typesupport_introspection_c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ * Add types `rosidl_pycommon` (`#824 `_) * Contributors: Michael Carlstrom diff --git a/rosidl_typesupport_introspection_c/package.xml b/rosidl_typesupport_introspection_c/package.xml index 1144c00c5..edc88d487 100644 --- a/rosidl_typesupport_introspection_c/package.xml +++ b/rosidl_typesupport_introspection_c/package.xml @@ -2,7 +2,7 @@ rosidl_typesupport_introspection_c - 4.8.1 + 4.9.0 Generate the message type support for dynamic message construction in C. diff --git a/rosidl_typesupport_introspection_cpp/CHANGELOG.rst b/rosidl_typesupport_introspection_cpp/CHANGELOG.rst index ef673e037..bc05f73ef 100644 --- a/rosidl_typesupport_introspection_cpp/CHANGELOG.rst +++ b/rosidl_typesupport_introspection_cpp/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_typesupport_introspection_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ * Add types `rosidl_pycommon` (`#824 `_) * Contributors: Michael Carlstrom diff --git a/rosidl_typesupport_introspection_cpp/package.xml b/rosidl_typesupport_introspection_cpp/package.xml index d5f09d731..6de5a550c 100644 --- a/rosidl_typesupport_introspection_cpp/package.xml +++ b/rosidl_typesupport_introspection_cpp/package.xml @@ -2,7 +2,7 @@ rosidl_typesupport_introspection_cpp - 4.8.1 + 4.9.0 Generate the message type support for dynamic message construction in C++. diff --git a/rosidl_typesupport_introspection_tests/CHANGELOG.rst b/rosidl_typesupport_introspection_tests/CHANGELOG.rst index 63baae4e1..481109a01 100644 --- a/rosidl_typesupport_introspection_tests/CHANGELOG.rst +++ b/rosidl_typesupport_introspection_tests/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package rosidl_typesupport_introspection_tests ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +4.9.0 (2024-10-03) +------------------ 4.8.1 (2024-06-25) ------------------ diff --git a/rosidl_typesupport_introspection_tests/package.xml b/rosidl_typesupport_introspection_tests/package.xml index 68e836738..f3dc152a3 100644 --- a/rosidl_typesupport_introspection_tests/package.xml +++ b/rosidl_typesupport_introspection_tests/package.xml @@ -2,7 +2,7 @@ rosidl_typesupport_introspection_tests - 4.8.1 + 4.9.0 Integration tests of the rosidl_typesupport_introspection_c/cpp packages. Aditya Pande From c71febca9493d7222eb1d6d67bacd129c56a3919 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Fri, 4 Oct 2024 03:53:14 -0400 Subject: [PATCH 3/4] Add types to rosidl_cli (#826) Signed-off-by: Michael Carlstrom --- rosidl_cli/package.xml | 1 + rosidl_cli/py.typed | 0 rosidl_cli/rosidl_cli/cli.py | 12 +++-- rosidl_cli/rosidl_cli/command/__init__.py | 6 ++- .../rosidl_cli/command/generate/__init__.py | 5 +- rosidl_cli/rosidl_cli/command/generate/api.py | 18 ++++--- .../rosidl_cli/command/generate/extensions.py | 27 ++++++---- rosidl_cli/rosidl_cli/command/helpers.py | 49 ++++++++++--------- .../rosidl_cli/command/translate/__init__.py | 6 ++- .../rosidl_cli/command/translate/api.py | 20 ++++---- .../command/translate/extensions.py | 23 ++++++--- rosidl_cli/rosidl_cli/common.py | 2 +- rosidl_cli/rosidl_cli/entry_points.py | 48 +++++++++--------- rosidl_cli/rosidl_cli/extensions.py | 31 +++++++----- rosidl_cli/test/rosidl_cli/test_common.py | 6 +-- rosidl_cli/test/rosidl_cli/test_extensions.py | 2 +- rosidl_cli/test/rosidl_cli/test_helpers.py | 7 +-- rosidl_cli/test/test_copyright.py | 2 +- rosidl_cli/test/test_flake8.py | 2 +- rosidl_cli/test/test_mypy.py | 23 +++++++++ rosidl_cli/test/test_pep257.py | 2 +- rosidl_cli/test/test_xmllint.py | 2 +- 22 files changed, 182 insertions(+), 112 deletions(-) create mode 100644 rosidl_cli/py.typed create mode 100644 rosidl_cli/test/test_mypy.py diff --git a/rosidl_cli/package.xml b/rosidl_cli/package.xml index 46f5c7ee5..e45804c7a 100644 --- a/rosidl_cli/package.xml +++ b/rosidl_cli/package.xml @@ -22,6 +22,7 @@ ament_copyright ament_flake8 + ament_mypy ament_pep257 ament_xmllint python3-pytest diff --git a/rosidl_cli/py.typed b/rosidl_cli/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/rosidl_cli/rosidl_cli/cli.py b/rosidl_cli/rosidl_cli/cli.py index 9c3f8ac28..ce729a816 100644 --- a/rosidl_cli/rosidl_cli/cli.py +++ b/rosidl_cli/rosidl_cli/cli.py @@ -14,13 +14,18 @@ import argparse import signal +from typing import Any, List, Union from rosidl_cli.command.generate import GenerateCommand from rosidl_cli.command.translate import TranslateCommand from rosidl_cli.common import get_first_line_doc -def add_subparsers(parser, cli_name, commands): +def add_subparsers( + parser: argparse.ArgumentParser, + cli_name: str, + commands: List[Union[GenerateCommand, TranslateCommand]] +) -> argparse._SubParsersAction[argparse.ArgumentParser]: """ Create argparse subparser for each command. @@ -63,7 +68,7 @@ def add_subparsers(parser, cli_name, commands): return subparser -def main(): +def main() -> Union[str, signal.Signals, Any]: script_name = 'rosidl' description = f'{script_name} is an extensible command-line tool ' \ 'for ROS interface generation.' @@ -74,7 +79,8 @@ def main(): formatter_class=argparse.RawDescriptionHelpFormatter ) - commands = [GenerateCommand(), TranslateCommand()] + commands: List[Union[GenerateCommand, TranslateCommand]] = \ + [GenerateCommand(), TranslateCommand()] # add arguments for command extension(s) add_subparsers( diff --git a/rosidl_cli/rosidl_cli/command/__init__.py b/rosidl_cli/rosidl_cli/command/__init__.py index 22d035bb5..187a6c187 100644 --- a/rosidl_cli/rosidl_cli/command/__init__.py +++ b/rosidl_cli/rosidl_cli/command/__init__.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import argparse + class Command: """ @@ -22,8 +24,8 @@ class Command: * `add_arguments` """ - def add_arguments(self, parser): + def add_arguments(self, parser: argparse.ArgumentParser) -> None: pass - def main(self, *, parser, args): + def main(self, *, args: argparse.Namespace) -> None: raise NotImplementedError() diff --git a/rosidl_cli/rosidl_cli/command/generate/__init__.py b/rosidl_cli/rosidl_cli/command/generate/__init__.py index ee46a937a..b12b946c1 100644 --- a/rosidl_cli/rosidl_cli/command/generate/__init__.py +++ b/rosidl_cli/rosidl_cli/command/generate/__init__.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import argparse import pathlib from rosidl_cli.command import Command @@ -24,7 +25,7 @@ class GenerateCommand(Command): name = 'generate' - def add_arguments(self, parser): + def add_arguments(self, parser: argparse.ArgumentParser) -> None: parser.add_argument( '-o', '--output-path', metavar='PATH', type=pathlib.Path, default=None, @@ -50,7 +51,7 @@ def add_arguments(self, parser): "If prefixed by another path followed by a colon ':', " 'path resolution is performed against such path.')) - def main(self, *, args): + def main(self, *, args: argparse.Namespace) -> None: generate( package_name=args.package_name, interface_files=args.interface_files, diff --git a/rosidl_cli/rosidl_cli/command/generate/api.py b/rosidl_cli/rosidl_cli/command/generate/api.py index ebec89144..ff7edbbcb 100644 --- a/rosidl_cli/rosidl_cli/command/generate/api.py +++ b/rosidl_cli/rosidl_cli/command/generate/api.py @@ -14,20 +14,22 @@ import os import pathlib +from typing import List, Optional +from .extensions import GenerateCommandExtension from .extensions import load_type_extensions from .extensions import load_typesupport_extensions def generate( *, - package_name, - interface_files, - include_paths=None, - output_path=None, - types=None, - typesupports=None -): + package_name: str, + interface_files: List[str], + include_paths: Optional[List[str]] = None, + output_path: Optional[pathlib.Path] = None, + types: Optional[List[str]] = None, + typesupports: Optional[List[str]] = None +) -> List[List[str]]: """ Generate source code from interface definition files. @@ -60,7 +62,7 @@ def generate( :returns: list of lists of paths to generated source code files, one group per type or type support extension invoked """ - extensions = [] + extensions: List[GenerateCommandExtension] = [] unspecific_generation = not types and not typesupports diff --git a/rosidl_cli/rosidl_cli/command/generate/extensions.py b/rosidl_cli/rosidl_cli/command/generate/extensions.py index fde1fb6b0..a89630d71 100644 --- a/rosidl_cli/rosidl_cli/command/generate/extensions.py +++ b/rosidl_cli/rosidl_cli/command/generate/extensions.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from pathlib import Path +from typing import cast, List, Optional + from rosidl_cli.extensions import Extension from rosidl_cli.extensions import load_extensions @@ -26,11 +29,11 @@ class GenerateCommandExtension(Extension): def generate( self, - package_name, - interface_files, - include_paths, - output_path - ): + package_name: str, + interface_files: List[str], + include_paths: List[str], + output_path: Path + ) -> List[str]: """ Generate source code. @@ -48,11 +51,17 @@ def generate( raise NotImplementedError() -def load_type_extensions(**kwargs): +def load_type_extensions(*, specs: Optional[List[str]], + strict: bool) -> List[GenerateCommandExtension]: """Load extensions for type representation source code generation.""" - return load_extensions('rosidl_cli.command.generate.type_extensions', **kwargs) + extensions = load_extensions('rosidl_cli.command.generate.type_extensions', specs=specs, + strict=strict) + return cast(List[GenerateCommandExtension], extensions) -def load_typesupport_extensions(**kwargs): +def load_typesupport_extensions(*, specs: Optional[List[str]], strict: bool + ) -> List[GenerateCommandExtension]: """Load extensions for type support source code generation.""" - return load_extensions('rosidl_cli.command.generate.typesupport_extensions', **kwargs) + extensions = load_extensions('rosidl_cli.command.generate.typesupport_extensions', + specs=specs, strict=strict) + return cast(List[GenerateCommandExtension], extensions) diff --git a/rosidl_cli/rosidl_cli/command/helpers.py b/rosidl_cli/rosidl_cli/command/helpers.py index f23cc9a88..d81b0cdc3 100644 --- a/rosidl_cli/rosidl_cli/command/helpers.py +++ b/rosidl_cli/rosidl_cli/command/helpers.py @@ -17,9 +17,10 @@ import os import pathlib import tempfile +from typing import Generator, List, Tuple -def package_name_from_interface_file_path(path): +def package_name_from_interface_file_path(path: pathlib.Path) -> str: """ Derive ROS package name from a ROS interface definition file path. @@ -29,7 +30,7 @@ def package_name_from_interface_file_path(path): return pathlib.Path(os.path.abspath(path)).parents[1].name -def dependencies_from_include_paths(include_paths): +def dependencies_from_include_paths(include_paths: List[str]) -> List[str]: """ Collect dependencies' ROS interface definition files from include paths. @@ -45,7 +46,7 @@ def dependencies_from_include_paths(include_paths): }) -def interface_path_as_tuple(path): +def interface_path_as_tuple(path: str) -> Tuple[pathlib.Path, pathlib.Path]: """ Express interface definition file path as an (absolute prefix, relative path) tuple. @@ -61,18 +62,20 @@ def interface_path_as_tuple(path): """ path_as_string = str(path) if ':' not in path_as_string: - prefix = pathlib.Path.cwd() + prefix_path = pathlib.Path.cwd() else: prefix, _, path = path_as_string.rpartition(':') - prefix = pathlib.Path(os.path.abspath(prefix)) - path = pathlib.Path(path) - if path.is_absolute(): + prefix_path = pathlib.Path(os.path.abspath(prefix)) + path_as_path = pathlib.Path(path) + if path_as_path.is_absolute(): raise ValueError('Interface definition file path ' - f"'{path}' cannot be absolute") - return prefix, path + f"'{path_as_path}' cannot be absolute") + return prefix_path, path_as_path -def idl_tuples_from_interface_files(interface_files): +def idl_tuples_from_interface_files( + interface_files: List[str] +) -> List[str]: """ Express ROS interface definition file paths as IDL tuples. @@ -80,9 +83,9 @@ def idl_tuples_from_interface_files(interface_files): which to resolve it followed by a colon ':'. This function then applies the same logic as `interface_path_as_tuple`. """ - idl_tuples = [] - for path in interface_files: - prefix, path = interface_path_as_tuple(path) + idl_tuples: List[str] = [] + for interface_path in interface_files: + prefix, path = interface_path_as_tuple(interface_path) idl_tuples.append(f'{prefix}:{path.as_posix()}') return idl_tuples @@ -90,12 +93,12 @@ def idl_tuples_from_interface_files(interface_files): @contextlib.contextmanager def legacy_generator_arguments_file( *, - package_name, - interface_files, - include_paths, - templates_path, - output_path -): + package_name: str, + interface_files: List[str], + include_paths: List[str], + templates_path: str, + output_path: str +) -> Generator[str, None, None]: """ Generate a temporary rosidl generator arguments file. @@ -138,10 +141,10 @@ def legacy_generator_arguments_file( def generate_visibility_control_file( *, - package_name, - template_path, - output_path -): + package_name: str, + template_path: str, + output_path: str +) -> None: """ Generate a visibility control file from a template. diff --git a/rosidl_cli/rosidl_cli/command/translate/__init__.py b/rosidl_cli/rosidl_cli/command/translate/__init__.py index 03798db3e..f5b6368f0 100644 --- a/rosidl_cli/rosidl_cli/command/translate/__init__.py +++ b/rosidl_cli/rosidl_cli/command/translate/__init__.py @@ -12,8 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import argparse import pathlib + from rosidl_cli.command import Command from .api import translate @@ -24,7 +26,7 @@ class TranslateCommand(Command): name = 'translate' - def add_arguments(self, parser): + def add_arguments(self, parser: argparse.ArgumentParser) -> None: parser.add_argument( '-o', '--output-path', metavar='PATH', type=pathlib.Path, default=None, @@ -64,7 +66,7 @@ def add_arguments(self, parser): 'path resolution is performed against such path.') ) - def main(self, *, args): + def main(self, *, args: argparse.Namespace) -> None: translate( package_name=args.package_name, interface_files=args.interface_files, diff --git a/rosidl_cli/rosidl_cli/command/translate/api.py b/rosidl_cli/rosidl_cli/command/translate/api.py index b63db278e..a7d18bd45 100644 --- a/rosidl_cli/rosidl_cli/command/translate/api.py +++ b/rosidl_cli/rosidl_cli/command/translate/api.py @@ -15,20 +15,21 @@ import collections import os import pathlib +from typing import DefaultDict, Dict, List, Optional, Union from .extensions import load_translate_extensions def translate( *, - package_name, - interface_files, - output_format, - input_format=None, - include_paths=None, - output_path=None, - translators=None -): + package_name: str, + interface_files: List[str], + output_format: str, + input_format: Optional[str] = None, + include_paths: Optional[List[str]] = None, + output_path: Optional[pathlib.Path] = None, + translators: Optional[List[str]] = None +) -> List[str]: """ Translate interface definition files from one format to another. @@ -64,7 +65,8 @@ def translate( raise RuntimeError('No translate extensions found') if not input_format: - interface_files_per_format = collections.defaultdict(list) + interface_files_per_format: Union[DefaultDict[str, List[str]], + Dict[str, List[str]]] = collections.defaultdict(list) for interface_file in interface_files: input_format = os.path.splitext(interface_file)[-1][1:] interface_files_per_format[input_format].append(interface_file) diff --git a/rosidl_cli/rosidl_cli/command/translate/extensions.py b/rosidl_cli/rosidl_cli/command/translate/extensions.py index f193a4804..10c3ba194 100644 --- a/rosidl_cli/rosidl_cli/command/translate/extensions.py +++ b/rosidl_cli/rosidl_cli/command/translate/extensions.py @@ -11,6 +11,8 @@ # 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 pathlib import Path +from typing import cast, ClassVar, List, Optional from rosidl_cli.extensions import Extension from rosidl_cli.extensions import load_extensions @@ -28,13 +30,16 @@ class TranslateCommandExtension(Extension): * `translate` """ + input_format: ClassVar[str] + output_format: ClassVar[str] + def translate( self, - package_name, - interface_files, - include_paths, - output_path - ): + package_name: str, + interface_files: List[str], + include_paths: List[str], + output_path: Path + ) -> List[str]: """ Translate interface definition files. @@ -57,8 +62,10 @@ def translate( raise NotImplementedError() -def load_translate_extensions(**kwargs): +def load_translate_extensions(*, specs: Optional[List[str]], strict: bool + ) -> List[TranslateCommandExtension]: """Load extensions for interface definition translation.""" - return load_extensions( - 'rosidl_cli.command.translate.extensions', **kwargs + extensions = load_extensions( + 'rosidl_cli.command.translate.extensions', specs=specs, strict=strict ) + return cast(List[TranslateCommandExtension], extensions) diff --git a/rosidl_cli/rosidl_cli/common.py b/rosidl_cli/rosidl_cli/common.py index 1f94c2c63..c0e8c9d42 100644 --- a/rosidl_cli/rosidl_cli/common.py +++ b/rosidl_cli/rosidl_cli/common.py @@ -13,7 +13,7 @@ # limitations under the License. -def get_first_line_doc(any_type): +def get_first_line_doc(any_type: object) -> str: if any_type.__doc__: for line in any_type.__doc__.splitlines(): line = line.strip() diff --git a/rosidl_cli/rosidl_cli/entry_points.py b/rosidl_cli/rosidl_cli/entry_points.py index edab63729..6d09f46c9 100644 --- a/rosidl_cli/rosidl_cli/entry_points.py +++ b/rosidl_cli/rosidl_cli/entry_points.py @@ -12,38 +12,39 @@ # See the License for the specific language governing permissions and # limitations under the License. +import importlib.metadata as importlib_metadata import logging - -try: - import importlib.metadata as importlib_metadata -except ModuleNotFoundError: - import importlib_metadata +import sys +from typing import Any, Dict, List, Optional, Tuple, Union logger = logging.getLogger(__name__) -def get_entry_points(group_name, *, specs=None, strict=False): +def get_entry_points(group_name: str, *, specs: Optional[List[str]] = None, strict: bool = False + ) -> Dict[str, importlib_metadata.EntryPoint]: """ Get entry points from a specific group. - :param str group_name: the name of the entry point group - :param list specs: an optional collection of entry point names to retrieve - :param bool strict: whether to raise or warn on error + :param group_name: the name of the entry point group + :param specs: an optional collection of entry point names to retrieve + :param strict: whether to raise or warn on error :returns: mapping from entry point names to ``EntryPoint`` instances - :rtype: dict """ if specs is not None: - specs = set(specs) + specs_set = set(specs) entry_points_impl = importlib_metadata.entry_points() - if hasattr(entry_points_impl, 'select'): + # Select does not exist until python 3.10 + if sys.version_info >= (3, 10): groups = entry_points_impl.select(group=group_name) else: - groups = entry_points_impl.get(group_name, []) - entry_points = {} + groups: Union[Tuple[importlib_metadata.EntryPoint, ...], + List[importlib_metadata.EntryPoint]] = entry_points_impl.get(group_name, []) + + entry_points: Dict[str, importlib_metadata.EntryPoint] = {} for entry_point in groups: name = entry_point.name - if specs and name not in specs: + if specs_set and name not in specs_set: continue if name in entry_points: msg = (f"Found duplicate entry point '{name}': " @@ -53,8 +54,8 @@ def get_entry_points(group_name, *, specs=None, strict=False): logger.warning(msg) continue entry_points[name] = entry_point - if specs: - pending = specs - set(entry_points) + if specs_set: + pending = specs_set - set(entry_points) if pending: msg = 'Some specs could not be met: ' msg += ', '.join(map(str, pending)) @@ -64,21 +65,22 @@ def get_entry_points(group_name, *, specs=None, strict=False): return entry_points -def load_entry_points(group_name, *, strict=False, **kwargs): +def load_entry_points(group_name: str, *, specs: Optional[List[str]], + strict: bool = False, + ) -> Dict[str, Any]: """ Load entry points for a specific group. See :py:meth:`get_entry_points` for further reference on additional keyword arguments. - :param str group_name: the name of the entry point group - :param bool strict: whether to raise or warn on error + :param group_name: the name of the entry point group + :param strict: whether to raise or warn on error :returns: mapping from entry point name to loaded entry point - :rtype: dict """ - loaded_entry_points = {} + loaded_entry_points: Dict[str, Any] = {} for name, entry_point in get_entry_points( - group_name, strict=strict, **kwargs + group_name, strict=strict, specs=specs ).items(): try: loaded_entry_points[name] = entry_point.load() diff --git a/rosidl_cli/rosidl_cli/extensions.py b/rosidl_cli/rosidl_cli/extensions.py index 7cc31afa2..bbc28c9e7 100644 --- a/rosidl_cli/rosidl_cli/extensions.py +++ b/rosidl_cli/rosidl_cli/extensions.py @@ -14,10 +14,19 @@ import logging import re +from typing import Any, Dict, Final, List, Optional, Tuple, TYPE_CHECKING, Union from rosidl_cli.entry_points import load_entry_points -import yaml +import yaml # type: ignore[import] + +if TYPE_CHECKING: + from typing import TypedDict + from typing_extensions import NotRequired + + class LoadExtensionsArg(TypedDict): + specs: NotRequired[Optional[List[str]]] + strict: NotRequired[bool] logger = logging.getLogger(__name__) @@ -26,18 +35,18 @@ class Extension: """A generic extension point.""" - def __init__(self, name): + def __init__(self, name: str) -> None: self.__name = name @property - def name(self): + def name(self) -> str: return self.__name -SPECS_PATTERN = re.compile(r'^(\w+)(?:\[(.+)\])?$') +SPECS_PATTERN: Final = re.compile(r'^(\w+)(?:\[(.+)\])?$') -def parse_extension_specification(spec): +def parse_extension_specification(spec: str) -> Tuple[Union[str, Any], Union[Dict[Any, Any], Any]]: """ Parse extension specification. @@ -64,18 +73,18 @@ def parse_extension_specification(spec): return name, kwargs -def load_extensions(group_name, *, specs=None, strict=False): +def load_extensions(group_name: str, *, specs: Optional[List[str]] = None, + strict: bool = False) -> List[Extension]: """ Load extensions for a specific group. - :param str group_name: the name of the extension group - :param list specs: an optional collection of extension specs + :param group_name: the name of the extension group + :param specs: an optional collection of extension specs (see :py:meth:`parse_extension_specification` for spec format) - :param bool strict: whether to raise or warn on error + :param strict: whether to raise or warn on error :returns: a list of :py:class:`Extension` instances - :rtype: list """ - extensions = [] + extensions: List[Extension] = [] if specs is not None: kwargs = dict(map( diff --git a/rosidl_cli/test/rosidl_cli/test_common.py b/rosidl_cli/test/rosidl_cli/test_common.py index 166f8bf0f..ccc4a6cb7 100644 --- a/rosidl_cli/test/rosidl_cli/test_common.py +++ b/rosidl_cli/test/rosidl_cli/test_common.py @@ -15,20 +15,20 @@ from rosidl_cli.common import get_first_line_doc -def test_getting_first_line_from_no_docstring(): +def test_getting_first_line_from_no_docstring() -> None: func = test_getting_first_line_from_no_docstring line = get_first_line_doc(func) assert line == '' -def test_getting_first_line_from_docstring(): +def test_getting_first_line_from_docstring() -> None: """Check it gets the first line.""" func = test_getting_first_line_from_docstring line = get_first_line_doc(func) assert line == 'Check it gets the first line' -def test_getting_first_line_from_multiline_docstring(): +def test_getting_first_line_from_multiline_docstring() -> None: """ Check it really gets the first non-empty line. diff --git a/rosidl_cli/test/rosidl_cli/test_extensions.py b/rosidl_cli/test/rosidl_cli/test_extensions.py index 7e3dd2158..94af493af 100644 --- a/rosidl_cli/test/rosidl_cli/test_extensions.py +++ b/rosidl_cli/test/rosidl_cli/test_extensions.py @@ -17,7 +17,7 @@ from rosidl_cli.extensions import parse_extension_specification -def test_extension_specification_parsing(): +def test_extension_specification_parsing() -> None: with pytest.raises(ValueError): parse_extension_specification('bad[') diff --git a/rosidl_cli/test/rosidl_cli/test_helpers.py b/rosidl_cli/test/rosidl_cli/test_helpers.py index 5a16f684f..bba66d4e9 100644 --- a/rosidl_cli/test/rosidl_cli/test_helpers.py +++ b/rosidl_cli/test/rosidl_cli/test_helpers.py @@ -15,6 +15,7 @@ import json import os import pathlib +from typing import Iterable import pytest @@ -22,7 +23,7 @@ from rosidl_cli.command.helpers import legacy_generator_arguments_file -def test_interface_path_as_tuple(): +def test_interface_path_as_tuple() -> None: prefix, path = interface_path_as_tuple('/tmp:msg/Empty.idl') assert pathlib.Path('msg/Empty.idl') == path assert pathlib.Path(os.path.abspath('/tmp')) == prefix @@ -37,7 +38,7 @@ def test_interface_path_as_tuple(): @pytest.fixture -def current_path(request): +def current_path(request: pytest.FixtureRequest) -> Iterable[pathlib.Path]: path = pathlib.Path(request.module.__file__) path = path.resolve() path = path.parent @@ -49,7 +50,7 @@ def current_path(request): os.chdir(str(cwd)) -def test_legacy_generator_arguments_file(current_path): +def test_legacy_generator_arguments_file(current_path: pathlib.Path) -> None: with legacy_generator_arguments_file( package_name='foo', interface_files=['msg/Foo.idl'], diff --git a/rosidl_cli/test/test_copyright.py b/rosidl_cli/test/test_copyright.py index cf0fae31f..66a7d63eb 100644 --- a/rosidl_cli/test/test_copyright.py +++ b/rosidl_cli/test/test_copyright.py @@ -18,6 +18,6 @@ @pytest.mark.copyright @pytest.mark.linter -def test_copyright(): +def test_copyright() -> None: rc = main(argv=['.', 'test']) assert rc == 0, 'Found errors' diff --git a/rosidl_cli/test/test_flake8.py b/rosidl_cli/test/test_flake8.py index 27ee1078f..eac16eef9 100644 --- a/rosidl_cli/test/test_flake8.py +++ b/rosidl_cli/test/test_flake8.py @@ -18,7 +18,7 @@ @pytest.mark.flake8 @pytest.mark.linter -def test_flake8(): +def test_flake8() -> None: rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ diff --git a/rosidl_cli/test/test_mypy.py b/rosidl_cli/test/test_mypy.py new file mode 100644 index 000000000..97e4f502a --- /dev/null +++ b/rosidl_cli/test/test_mypy.py @@ -0,0 +1,23 @@ +# 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!' diff --git a/rosidl_cli/test/test_pep257.py b/rosidl_cli/test/test_pep257.py index 0e38a6c60..4ae521a5a 100644 --- a/rosidl_cli/test/test_pep257.py +++ b/rosidl_cli/test/test_pep257.py @@ -18,6 +18,6 @@ @pytest.mark.linter @pytest.mark.pep257 -def test_pep257(): +def test_pep257() -> None: rc = main(argv=[]) assert rc == 0, 'Found code style errors / warnings' diff --git a/rosidl_cli/test/test_xmllint.py b/rosidl_cli/test/test_xmllint.py index f46285e71..08bf7fd78 100644 --- a/rosidl_cli/test/test_xmllint.py +++ b/rosidl_cli/test/test_xmllint.py @@ -18,6 +18,6 @@ @pytest.mark.linter @pytest.mark.xmllint -def test_xmllint(): +def test_xmllint() -> None: rc = main(argv=[]) assert rc == 0, 'Found errors' From 21fa68f25b1d43a5f79b6575ff87431615f6c9f3 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Mon, 7 Oct 2024 04:03:54 -0400 Subject: [PATCH 4/4] Revert "Add types to rosidl_cli (#826)" (#830) This reverts commit c71febca9493d7222eb1d6d67bacd129c56a3919. --- rosidl_cli/package.xml | 1 - rosidl_cli/py.typed | 0 rosidl_cli/rosidl_cli/cli.py | 12 ++--- rosidl_cli/rosidl_cli/command/__init__.py | 6 +-- .../rosidl_cli/command/generate/__init__.py | 5 +- rosidl_cli/rosidl_cli/command/generate/api.py | 18 +++---- .../rosidl_cli/command/generate/extensions.py | 27 ++++------ rosidl_cli/rosidl_cli/command/helpers.py | 49 +++++++++---------- .../rosidl_cli/command/translate/__init__.py | 6 +-- .../rosidl_cli/command/translate/api.py | 20 ++++---- .../command/translate/extensions.py | 23 +++------ rosidl_cli/rosidl_cli/common.py | 2 +- rosidl_cli/rosidl_cli/entry_points.py | 48 +++++++++--------- rosidl_cli/rosidl_cli/extensions.py | 31 +++++------- rosidl_cli/test/rosidl_cli/test_common.py | 6 +-- rosidl_cli/test/rosidl_cli/test_extensions.py | 2 +- rosidl_cli/test/rosidl_cli/test_helpers.py | 7 ++- rosidl_cli/test/test_copyright.py | 2 +- rosidl_cli/test/test_flake8.py | 2 +- rosidl_cli/test/test_mypy.py | 23 --------- rosidl_cli/test/test_pep257.py | 2 +- rosidl_cli/test/test_xmllint.py | 2 +- 22 files changed, 112 insertions(+), 182 deletions(-) delete mode 100644 rosidl_cli/py.typed delete mode 100644 rosidl_cli/test/test_mypy.py diff --git a/rosidl_cli/package.xml b/rosidl_cli/package.xml index e45804c7a..46f5c7ee5 100644 --- a/rosidl_cli/package.xml +++ b/rosidl_cli/package.xml @@ -22,7 +22,6 @@ ament_copyright ament_flake8 - ament_mypy ament_pep257 ament_xmllint python3-pytest diff --git a/rosidl_cli/py.typed b/rosidl_cli/py.typed deleted file mode 100644 index e69de29bb..000000000 diff --git a/rosidl_cli/rosidl_cli/cli.py b/rosidl_cli/rosidl_cli/cli.py index ce729a816..9c3f8ac28 100644 --- a/rosidl_cli/rosidl_cli/cli.py +++ b/rosidl_cli/rosidl_cli/cli.py @@ -14,18 +14,13 @@ import argparse import signal -from typing import Any, List, Union from rosidl_cli.command.generate import GenerateCommand from rosidl_cli.command.translate import TranslateCommand from rosidl_cli.common import get_first_line_doc -def add_subparsers( - parser: argparse.ArgumentParser, - cli_name: str, - commands: List[Union[GenerateCommand, TranslateCommand]] -) -> argparse._SubParsersAction[argparse.ArgumentParser]: +def add_subparsers(parser, cli_name, commands): """ Create argparse subparser for each command. @@ -68,7 +63,7 @@ def add_subparsers( return subparser -def main() -> Union[str, signal.Signals, Any]: +def main(): script_name = 'rosidl' description = f'{script_name} is an extensible command-line tool ' \ 'for ROS interface generation.' @@ -79,8 +74,7 @@ def main() -> Union[str, signal.Signals, Any]: formatter_class=argparse.RawDescriptionHelpFormatter ) - commands: List[Union[GenerateCommand, TranslateCommand]] = \ - [GenerateCommand(), TranslateCommand()] + commands = [GenerateCommand(), TranslateCommand()] # add arguments for command extension(s) add_subparsers( diff --git a/rosidl_cli/rosidl_cli/command/__init__.py b/rosidl_cli/rosidl_cli/command/__init__.py index 187a6c187..22d035bb5 100644 --- a/rosidl_cli/rosidl_cli/command/__init__.py +++ b/rosidl_cli/rosidl_cli/command/__init__.py @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import argparse - class Command: """ @@ -24,8 +22,8 @@ class Command: * `add_arguments` """ - def add_arguments(self, parser: argparse.ArgumentParser) -> None: + def add_arguments(self, parser): pass - def main(self, *, args: argparse.Namespace) -> None: + def main(self, *, parser, args): raise NotImplementedError() diff --git a/rosidl_cli/rosidl_cli/command/generate/__init__.py b/rosidl_cli/rosidl_cli/command/generate/__init__.py index b12b946c1..ee46a937a 100644 --- a/rosidl_cli/rosidl_cli/command/generate/__init__.py +++ b/rosidl_cli/rosidl_cli/command/generate/__init__.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import argparse import pathlib from rosidl_cli.command import Command @@ -25,7 +24,7 @@ class GenerateCommand(Command): name = 'generate' - def add_arguments(self, parser: argparse.ArgumentParser) -> None: + def add_arguments(self, parser): parser.add_argument( '-o', '--output-path', metavar='PATH', type=pathlib.Path, default=None, @@ -51,7 +50,7 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None: "If prefixed by another path followed by a colon ':', " 'path resolution is performed against such path.')) - def main(self, *, args: argparse.Namespace) -> None: + def main(self, *, args): generate( package_name=args.package_name, interface_files=args.interface_files, diff --git a/rosidl_cli/rosidl_cli/command/generate/api.py b/rosidl_cli/rosidl_cli/command/generate/api.py index ff7edbbcb..ebec89144 100644 --- a/rosidl_cli/rosidl_cli/command/generate/api.py +++ b/rosidl_cli/rosidl_cli/command/generate/api.py @@ -14,22 +14,20 @@ import os import pathlib -from typing import List, Optional -from .extensions import GenerateCommandExtension from .extensions import load_type_extensions from .extensions import load_typesupport_extensions def generate( *, - package_name: str, - interface_files: List[str], - include_paths: Optional[List[str]] = None, - output_path: Optional[pathlib.Path] = None, - types: Optional[List[str]] = None, - typesupports: Optional[List[str]] = None -) -> List[List[str]]: + package_name, + interface_files, + include_paths=None, + output_path=None, + types=None, + typesupports=None +): """ Generate source code from interface definition files. @@ -62,7 +60,7 @@ def generate( :returns: list of lists of paths to generated source code files, one group per type or type support extension invoked """ - extensions: List[GenerateCommandExtension] = [] + extensions = [] unspecific_generation = not types and not typesupports diff --git a/rosidl_cli/rosidl_cli/command/generate/extensions.py b/rosidl_cli/rosidl_cli/command/generate/extensions.py index a89630d71..fde1fb6b0 100644 --- a/rosidl_cli/rosidl_cli/command/generate/extensions.py +++ b/rosidl_cli/rosidl_cli/command/generate/extensions.py @@ -12,9 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from pathlib import Path -from typing import cast, List, Optional - from rosidl_cli.extensions import Extension from rosidl_cli.extensions import load_extensions @@ -29,11 +26,11 @@ class GenerateCommandExtension(Extension): def generate( self, - package_name: str, - interface_files: List[str], - include_paths: List[str], - output_path: Path - ) -> List[str]: + package_name, + interface_files, + include_paths, + output_path + ): """ Generate source code. @@ -51,17 +48,11 @@ def generate( raise NotImplementedError() -def load_type_extensions(*, specs: Optional[List[str]], - strict: bool) -> List[GenerateCommandExtension]: +def load_type_extensions(**kwargs): """Load extensions for type representation source code generation.""" - extensions = load_extensions('rosidl_cli.command.generate.type_extensions', specs=specs, - strict=strict) - return cast(List[GenerateCommandExtension], extensions) + return load_extensions('rosidl_cli.command.generate.type_extensions', **kwargs) -def load_typesupport_extensions(*, specs: Optional[List[str]], strict: bool - ) -> List[GenerateCommandExtension]: +def load_typesupport_extensions(**kwargs): """Load extensions for type support source code generation.""" - extensions = load_extensions('rosidl_cli.command.generate.typesupport_extensions', - specs=specs, strict=strict) - return cast(List[GenerateCommandExtension], extensions) + return load_extensions('rosidl_cli.command.generate.typesupport_extensions', **kwargs) diff --git a/rosidl_cli/rosidl_cli/command/helpers.py b/rosidl_cli/rosidl_cli/command/helpers.py index d81b0cdc3..f23cc9a88 100644 --- a/rosidl_cli/rosidl_cli/command/helpers.py +++ b/rosidl_cli/rosidl_cli/command/helpers.py @@ -17,10 +17,9 @@ import os import pathlib import tempfile -from typing import Generator, List, Tuple -def package_name_from_interface_file_path(path: pathlib.Path) -> str: +def package_name_from_interface_file_path(path): """ Derive ROS package name from a ROS interface definition file path. @@ -30,7 +29,7 @@ def package_name_from_interface_file_path(path: pathlib.Path) -> str: return pathlib.Path(os.path.abspath(path)).parents[1].name -def dependencies_from_include_paths(include_paths: List[str]) -> List[str]: +def dependencies_from_include_paths(include_paths): """ Collect dependencies' ROS interface definition files from include paths. @@ -46,7 +45,7 @@ def dependencies_from_include_paths(include_paths: List[str]) -> List[str]: }) -def interface_path_as_tuple(path: str) -> Tuple[pathlib.Path, pathlib.Path]: +def interface_path_as_tuple(path): """ Express interface definition file path as an (absolute prefix, relative path) tuple. @@ -62,20 +61,18 @@ def interface_path_as_tuple(path: str) -> Tuple[pathlib.Path, pathlib.Path]: """ path_as_string = str(path) if ':' not in path_as_string: - prefix_path = pathlib.Path.cwd() + prefix = pathlib.Path.cwd() else: prefix, _, path = path_as_string.rpartition(':') - prefix_path = pathlib.Path(os.path.abspath(prefix)) - path_as_path = pathlib.Path(path) - if path_as_path.is_absolute(): + prefix = pathlib.Path(os.path.abspath(prefix)) + path = pathlib.Path(path) + if path.is_absolute(): raise ValueError('Interface definition file path ' - f"'{path_as_path}' cannot be absolute") - return prefix_path, path_as_path + f"'{path}' cannot be absolute") + return prefix, path -def idl_tuples_from_interface_files( - interface_files: List[str] -) -> List[str]: +def idl_tuples_from_interface_files(interface_files): """ Express ROS interface definition file paths as IDL tuples. @@ -83,9 +80,9 @@ def idl_tuples_from_interface_files( which to resolve it followed by a colon ':'. This function then applies the same logic as `interface_path_as_tuple`. """ - idl_tuples: List[str] = [] - for interface_path in interface_files: - prefix, path = interface_path_as_tuple(interface_path) + idl_tuples = [] + for path in interface_files: + prefix, path = interface_path_as_tuple(path) idl_tuples.append(f'{prefix}:{path.as_posix()}') return idl_tuples @@ -93,12 +90,12 @@ def idl_tuples_from_interface_files( @contextlib.contextmanager def legacy_generator_arguments_file( *, - package_name: str, - interface_files: List[str], - include_paths: List[str], - templates_path: str, - output_path: str -) -> Generator[str, None, None]: + package_name, + interface_files, + include_paths, + templates_path, + output_path +): """ Generate a temporary rosidl generator arguments file. @@ -141,10 +138,10 @@ def legacy_generator_arguments_file( def generate_visibility_control_file( *, - package_name: str, - template_path: str, - output_path: str -) -> None: + package_name, + template_path, + output_path +): """ Generate a visibility control file from a template. diff --git a/rosidl_cli/rosidl_cli/command/translate/__init__.py b/rosidl_cli/rosidl_cli/command/translate/__init__.py index f5b6368f0..03798db3e 100644 --- a/rosidl_cli/rosidl_cli/command/translate/__init__.py +++ b/rosidl_cli/rosidl_cli/command/translate/__init__.py @@ -12,10 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import argparse import pathlib - from rosidl_cli.command import Command from .api import translate @@ -26,7 +24,7 @@ class TranslateCommand(Command): name = 'translate' - def add_arguments(self, parser: argparse.ArgumentParser) -> None: + def add_arguments(self, parser): parser.add_argument( '-o', '--output-path', metavar='PATH', type=pathlib.Path, default=None, @@ -66,7 +64,7 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None: 'path resolution is performed against such path.') ) - def main(self, *, args: argparse.Namespace) -> None: + def main(self, *, args): translate( package_name=args.package_name, interface_files=args.interface_files, diff --git a/rosidl_cli/rosidl_cli/command/translate/api.py b/rosidl_cli/rosidl_cli/command/translate/api.py index a7d18bd45..b63db278e 100644 --- a/rosidl_cli/rosidl_cli/command/translate/api.py +++ b/rosidl_cli/rosidl_cli/command/translate/api.py @@ -15,21 +15,20 @@ import collections import os import pathlib -from typing import DefaultDict, Dict, List, Optional, Union from .extensions import load_translate_extensions def translate( *, - package_name: str, - interface_files: List[str], - output_format: str, - input_format: Optional[str] = None, - include_paths: Optional[List[str]] = None, - output_path: Optional[pathlib.Path] = None, - translators: Optional[List[str]] = None -) -> List[str]: + package_name, + interface_files, + output_format, + input_format=None, + include_paths=None, + output_path=None, + translators=None +): """ Translate interface definition files from one format to another. @@ -65,8 +64,7 @@ def translate( raise RuntimeError('No translate extensions found') if not input_format: - interface_files_per_format: Union[DefaultDict[str, List[str]], - Dict[str, List[str]]] = collections.defaultdict(list) + interface_files_per_format = collections.defaultdict(list) for interface_file in interface_files: input_format = os.path.splitext(interface_file)[-1][1:] interface_files_per_format[input_format].append(interface_file) diff --git a/rosidl_cli/rosidl_cli/command/translate/extensions.py b/rosidl_cli/rosidl_cli/command/translate/extensions.py index 10c3ba194..f193a4804 100644 --- a/rosidl_cli/rosidl_cli/command/translate/extensions.py +++ b/rosidl_cli/rosidl_cli/command/translate/extensions.py @@ -11,8 +11,6 @@ # 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 pathlib import Path -from typing import cast, ClassVar, List, Optional from rosidl_cli.extensions import Extension from rosidl_cli.extensions import load_extensions @@ -30,16 +28,13 @@ class TranslateCommandExtension(Extension): * `translate` """ - input_format: ClassVar[str] - output_format: ClassVar[str] - def translate( self, - package_name: str, - interface_files: List[str], - include_paths: List[str], - output_path: Path - ) -> List[str]: + package_name, + interface_files, + include_paths, + output_path + ): """ Translate interface definition files. @@ -62,10 +57,8 @@ def translate( raise NotImplementedError() -def load_translate_extensions(*, specs: Optional[List[str]], strict: bool - ) -> List[TranslateCommandExtension]: +def load_translate_extensions(**kwargs): """Load extensions for interface definition translation.""" - extensions = load_extensions( - 'rosidl_cli.command.translate.extensions', specs=specs, strict=strict + return load_extensions( + 'rosidl_cli.command.translate.extensions', **kwargs ) - return cast(List[TranslateCommandExtension], extensions) diff --git a/rosidl_cli/rosidl_cli/common.py b/rosidl_cli/rosidl_cli/common.py index c0e8c9d42..1f94c2c63 100644 --- a/rosidl_cli/rosidl_cli/common.py +++ b/rosidl_cli/rosidl_cli/common.py @@ -13,7 +13,7 @@ # limitations under the License. -def get_first_line_doc(any_type: object) -> str: +def get_first_line_doc(any_type): if any_type.__doc__: for line in any_type.__doc__.splitlines(): line = line.strip() diff --git a/rosidl_cli/rosidl_cli/entry_points.py b/rosidl_cli/rosidl_cli/entry_points.py index 6d09f46c9..edab63729 100644 --- a/rosidl_cli/rosidl_cli/entry_points.py +++ b/rosidl_cli/rosidl_cli/entry_points.py @@ -12,39 +12,38 @@ # See the License for the specific language governing permissions and # limitations under the License. -import importlib.metadata as importlib_metadata import logging -import sys -from typing import Any, Dict, List, Optional, Tuple, Union + +try: + import importlib.metadata as importlib_metadata +except ModuleNotFoundError: + import importlib_metadata logger = logging.getLogger(__name__) -def get_entry_points(group_name: str, *, specs: Optional[List[str]] = None, strict: bool = False - ) -> Dict[str, importlib_metadata.EntryPoint]: +def get_entry_points(group_name, *, specs=None, strict=False): """ Get entry points from a specific group. - :param group_name: the name of the entry point group - :param specs: an optional collection of entry point names to retrieve - :param strict: whether to raise or warn on error + :param str group_name: the name of the entry point group + :param list specs: an optional collection of entry point names to retrieve + :param bool strict: whether to raise or warn on error :returns: mapping from entry point names to ``EntryPoint`` instances + :rtype: dict """ if specs is not None: - specs_set = set(specs) + specs = set(specs) entry_points_impl = importlib_metadata.entry_points() - # Select does not exist until python 3.10 - if sys.version_info >= (3, 10): + if hasattr(entry_points_impl, 'select'): groups = entry_points_impl.select(group=group_name) else: - groups: Union[Tuple[importlib_metadata.EntryPoint, ...], - List[importlib_metadata.EntryPoint]] = entry_points_impl.get(group_name, []) - - entry_points: Dict[str, importlib_metadata.EntryPoint] = {} + groups = entry_points_impl.get(group_name, []) + entry_points = {} for entry_point in groups: name = entry_point.name - if specs_set and name not in specs_set: + if specs and name not in specs: continue if name in entry_points: msg = (f"Found duplicate entry point '{name}': " @@ -54,8 +53,8 @@ def get_entry_points(group_name: str, *, specs: Optional[List[str]] = None, stri logger.warning(msg) continue entry_points[name] = entry_point - if specs_set: - pending = specs_set - set(entry_points) + if specs: + pending = specs - set(entry_points) if pending: msg = 'Some specs could not be met: ' msg += ', '.join(map(str, pending)) @@ -65,22 +64,21 @@ def get_entry_points(group_name: str, *, specs: Optional[List[str]] = None, stri return entry_points -def load_entry_points(group_name: str, *, specs: Optional[List[str]], - strict: bool = False, - ) -> Dict[str, Any]: +def load_entry_points(group_name, *, strict=False, **kwargs): """ Load entry points for a specific group. See :py:meth:`get_entry_points` for further reference on additional keyword arguments. - :param group_name: the name of the entry point group - :param strict: whether to raise or warn on error + :param str group_name: the name of the entry point group + :param bool strict: whether to raise or warn on error :returns: mapping from entry point name to loaded entry point + :rtype: dict """ - loaded_entry_points: Dict[str, Any] = {} + loaded_entry_points = {} for name, entry_point in get_entry_points( - group_name, strict=strict, specs=specs + group_name, strict=strict, **kwargs ).items(): try: loaded_entry_points[name] = entry_point.load() diff --git a/rosidl_cli/rosidl_cli/extensions.py b/rosidl_cli/rosidl_cli/extensions.py index bbc28c9e7..7cc31afa2 100644 --- a/rosidl_cli/rosidl_cli/extensions.py +++ b/rosidl_cli/rosidl_cli/extensions.py @@ -14,19 +14,10 @@ import logging import re -from typing import Any, Dict, Final, List, Optional, Tuple, TYPE_CHECKING, Union from rosidl_cli.entry_points import load_entry_points -import yaml # type: ignore[import] - -if TYPE_CHECKING: - from typing import TypedDict - from typing_extensions import NotRequired - - class LoadExtensionsArg(TypedDict): - specs: NotRequired[Optional[List[str]]] - strict: NotRequired[bool] +import yaml logger = logging.getLogger(__name__) @@ -35,18 +26,18 @@ class LoadExtensionsArg(TypedDict): class Extension: """A generic extension point.""" - def __init__(self, name: str) -> None: + def __init__(self, name): self.__name = name @property - def name(self) -> str: + def name(self): return self.__name -SPECS_PATTERN: Final = re.compile(r'^(\w+)(?:\[(.+)\])?$') +SPECS_PATTERN = re.compile(r'^(\w+)(?:\[(.+)\])?$') -def parse_extension_specification(spec: str) -> Tuple[Union[str, Any], Union[Dict[Any, Any], Any]]: +def parse_extension_specification(spec): """ Parse extension specification. @@ -73,18 +64,18 @@ def parse_extension_specification(spec: str) -> Tuple[Union[str, Any], Union[Dic return name, kwargs -def load_extensions(group_name: str, *, specs: Optional[List[str]] = None, - strict: bool = False) -> List[Extension]: +def load_extensions(group_name, *, specs=None, strict=False): """ Load extensions for a specific group. - :param group_name: the name of the extension group - :param specs: an optional collection of extension specs + :param str group_name: the name of the extension group + :param list specs: an optional collection of extension specs (see :py:meth:`parse_extension_specification` for spec format) - :param strict: whether to raise or warn on error + :param bool strict: whether to raise or warn on error :returns: a list of :py:class:`Extension` instances + :rtype: list """ - extensions: List[Extension] = [] + extensions = [] if specs is not None: kwargs = dict(map( diff --git a/rosidl_cli/test/rosidl_cli/test_common.py b/rosidl_cli/test/rosidl_cli/test_common.py index ccc4a6cb7..166f8bf0f 100644 --- a/rosidl_cli/test/rosidl_cli/test_common.py +++ b/rosidl_cli/test/rosidl_cli/test_common.py @@ -15,20 +15,20 @@ from rosidl_cli.common import get_first_line_doc -def test_getting_first_line_from_no_docstring() -> None: +def test_getting_first_line_from_no_docstring(): func = test_getting_first_line_from_no_docstring line = get_first_line_doc(func) assert line == '' -def test_getting_first_line_from_docstring() -> None: +def test_getting_first_line_from_docstring(): """Check it gets the first line.""" func = test_getting_first_line_from_docstring line = get_first_line_doc(func) assert line == 'Check it gets the first line' -def test_getting_first_line_from_multiline_docstring() -> None: +def test_getting_first_line_from_multiline_docstring(): """ Check it really gets the first non-empty line. diff --git a/rosidl_cli/test/rosidl_cli/test_extensions.py b/rosidl_cli/test/rosidl_cli/test_extensions.py index 94af493af..7e3dd2158 100644 --- a/rosidl_cli/test/rosidl_cli/test_extensions.py +++ b/rosidl_cli/test/rosidl_cli/test_extensions.py @@ -17,7 +17,7 @@ from rosidl_cli.extensions import parse_extension_specification -def test_extension_specification_parsing() -> None: +def test_extension_specification_parsing(): with pytest.raises(ValueError): parse_extension_specification('bad[') diff --git a/rosidl_cli/test/rosidl_cli/test_helpers.py b/rosidl_cli/test/rosidl_cli/test_helpers.py index bba66d4e9..5a16f684f 100644 --- a/rosidl_cli/test/rosidl_cli/test_helpers.py +++ b/rosidl_cli/test/rosidl_cli/test_helpers.py @@ -15,7 +15,6 @@ import json import os import pathlib -from typing import Iterable import pytest @@ -23,7 +22,7 @@ from rosidl_cli.command.helpers import legacy_generator_arguments_file -def test_interface_path_as_tuple() -> None: +def test_interface_path_as_tuple(): prefix, path = interface_path_as_tuple('/tmp:msg/Empty.idl') assert pathlib.Path('msg/Empty.idl') == path assert pathlib.Path(os.path.abspath('/tmp')) == prefix @@ -38,7 +37,7 @@ def test_interface_path_as_tuple() -> None: @pytest.fixture -def current_path(request: pytest.FixtureRequest) -> Iterable[pathlib.Path]: +def current_path(request): path = pathlib.Path(request.module.__file__) path = path.resolve() path = path.parent @@ -50,7 +49,7 @@ def current_path(request: pytest.FixtureRequest) -> Iterable[pathlib.Path]: os.chdir(str(cwd)) -def test_legacy_generator_arguments_file(current_path: pathlib.Path) -> None: +def test_legacy_generator_arguments_file(current_path): with legacy_generator_arguments_file( package_name='foo', interface_files=['msg/Foo.idl'], diff --git a/rosidl_cli/test/test_copyright.py b/rosidl_cli/test/test_copyright.py index 66a7d63eb..cf0fae31f 100644 --- a/rosidl_cli/test/test_copyright.py +++ b/rosidl_cli/test/test_copyright.py @@ -18,6 +18,6 @@ @pytest.mark.copyright @pytest.mark.linter -def test_copyright() -> None: +def test_copyright(): rc = main(argv=['.', 'test']) assert rc == 0, 'Found errors' diff --git a/rosidl_cli/test/test_flake8.py b/rosidl_cli/test/test_flake8.py index eac16eef9..27ee1078f 100644 --- a/rosidl_cli/test/test_flake8.py +++ b/rosidl_cli/test/test_flake8.py @@ -18,7 +18,7 @@ @pytest.mark.flake8 @pytest.mark.linter -def test_flake8() -> None: +def test_flake8(): rc, errors = main_with_errors(argv=[]) assert rc == 0, \ 'Found %d code style errors / warnings:\n' % len(errors) + \ diff --git a/rosidl_cli/test/test_mypy.py b/rosidl_cli/test/test_mypy.py deleted file mode 100644 index 97e4f502a..000000000 --- a/rosidl_cli/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!' diff --git a/rosidl_cli/test/test_pep257.py b/rosidl_cli/test/test_pep257.py index 4ae521a5a..0e38a6c60 100644 --- a/rosidl_cli/test/test_pep257.py +++ b/rosidl_cli/test/test_pep257.py @@ -18,6 +18,6 @@ @pytest.mark.linter @pytest.mark.pep257 -def test_pep257() -> None: +def test_pep257(): rc = main(argv=[]) assert rc == 0, 'Found code style errors / warnings' diff --git a/rosidl_cli/test/test_xmllint.py b/rosidl_cli/test/test_xmllint.py index 08bf7fd78..f46285e71 100644 --- a/rosidl_cli/test/test_xmllint.py +++ b/rosidl_cli/test/test_xmllint.py @@ -18,6 +18,6 @@ @pytest.mark.linter @pytest.mark.xmllint -def test_xmllint() -> None: +def test_xmllint(): rc = main(argv=[]) assert rc == 0, 'Found errors'