From 1eb4208126e81794f40b01c2ba69e00590ef9e57 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Thu, 8 Aug 2024 18:01:53 -0400 Subject: [PATCH] Replace rclpyHandle with type stubs (#1326) * Replace rclpyHandle with stubs Signed-off-by: Michael Carlstrom * Rerun CI Signed-off-by: Michael Carlstrom * Rerun CI Signed-off-by: Michael Carlstrom --------- Signed-off-by: Michael Carlstrom Co-authored-by: Shane Loretz --- rclpy/rclpy/impl/_rclpy_pybind11.pyi | 22 +++++++++++++++++++ rclpy/rclpy/impl/implementation_singleton.py | 14 +----------- rclpy/rclpy/impl/implementation_singleton.pyi | 18 +++++++++++++++ 3 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 rclpy/rclpy/impl/_rclpy_pybind11.pyi create mode 100644 rclpy/rclpy/impl/implementation_singleton.pyi diff --git a/rclpy/rclpy/impl/_rclpy_pybind11.pyi b/rclpy/rclpy/impl/_rclpy_pybind11.pyi new file mode 100644 index 000000000..df259e477 --- /dev/null +++ b/rclpy/rclpy/impl/_rclpy_pybind11.pyi @@ -0,0 +1,22 @@ +# 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 typing import Sequence + + +def rclpy_remove_ros_args(pycli_args: Sequence[str]) -> list[str]: ... +"""Remove ROS-specific arguments from argument vector.""" + +def rclpy_get_rmw_implementation_identifier() -> str: ... +"""Retrieve the identifier for the active RMW implementation.""" diff --git a/rclpy/rclpy/impl/implementation_singleton.py b/rclpy/rclpy/impl/implementation_singleton.py index cdbfc0b00..ba7f55fe8 100644 --- a/rclpy/rclpy/impl/implementation_singleton.py +++ b/rclpy/rclpy/impl/implementation_singleton.py @@ -26,19 +26,7 @@ # ... """ - -from typing import List, Protocol, Sequence - from rpyutils import import_c_library package = 'rclpy' -rclpy_implementation: 'rclpyHandle' = import_c_library('._rclpy_pybind11', package) - - -class rclpyHandle(Protocol): - - def rclpy_remove_ros_args(self, pycli_args: Sequence[str]) -> List[str]: - ... - - def rclpy_get_rmw_implementation_identifier(self) -> str: - ... +rclpy_implementation = import_c_library('._rclpy_pybind11', package) diff --git a/rclpy/rclpy/impl/implementation_singleton.pyi b/rclpy/rclpy/impl/implementation_singleton.pyi new file mode 100644 index 000000000..a1e16bdf9 --- /dev/null +++ b/rclpy/rclpy/impl/implementation_singleton.pyi @@ -0,0 +1,18 @@ +# 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 rclpy.impl import _rclpy_pybind11 + +rclpy_implementation = _rclpy_pybind11