Skip to content

Commit 61174c4

Browse files
committed
Drop the Kilted support
1 parent bc46bf6 commit 61174c4

File tree

1 file changed

+19
-80
lines changed

1 file changed

+19
-80
lines changed

rosbridge_library/src/rosbridge_library/internal/type_support.py

Lines changed: 19 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -32,55 +32,17 @@
3232

3333
from __future__ import annotations
3434

35-
from typing import Any, Protocol, TypeVar, runtime_checkable
35+
from typing import Any, TypeAlias, TypeVar
3636

3737
from rclpy.action.client import ActionClient as _ActionClient
3838
from rclpy.action.client import ClientGoalHandle as _ClientGoalHandle
3939
from rclpy.action.server import ActionServer as _ActionServer
4040
from rclpy.action.server import ServerGoalHandle as _ServerGoalHandle
41+
from rosidl_pycommon.interface_base_classes import BaseAction, BaseImpl, BaseMessage, BaseService
4142

42-
try:
43-
from rosidl_pycommon.interface_base_classes import (
44-
BaseAction,
45-
BaseMessage,
46-
BaseService,
47-
)
48-
49-
ROSMessage = BaseMessage
50-
ROSService = BaseService
51-
ROSAction = BaseAction
52-
53-
except ImportError:
54-
# Fallback to Protocols if interface base classes are not available
55-
# TODO: Remove this fallback once we drop support for Kilted
56-
57-
@runtime_checkable
58-
class ROSMessage(Protocol): # type: ignore[no-redef]
59-
"""Protocol for ROS message types."""
60-
61-
__slots__: list[str]
62-
_fields_and_field_types: dict[str, str]
63-
64-
def get_fields_and_field_types(self) -> dict[str, str]:
65-
"""Return a dictionary of field names to field types."""
66-
67-
@runtime_checkable
68-
class ROSService(Protocol): # type: ignore[no-redef]
69-
"""Protocol for ROS service types."""
70-
71-
Request: type[ROSMessage]
72-
Response: type[ROSMessage]
73-
Event: type[ROSMessage]
74-
75-
@runtime_checkable
76-
class ROSAction(Protocol): # type: ignore[no-redef]
77-
"""Protocol for ROS action types."""
78-
79-
Goal: type[ROSMessage]
80-
Result: type[ROSMessage]
81-
Feedback: type[ROSMessage]
82-
Impl: type[Any]
83-
43+
ROSMessage: TypeAlias = BaseMessage
44+
ROSService: TypeAlias = BaseService
45+
ROSAction: TypeAlias = BaseAction
8446

8547
# Type variables for ROS types
8648
ROSMessageT = TypeVar("ROSMessageT", bound=ROSMessage)
@@ -91,40 +53,17 @@ class ROSAction(Protocol): # type: ignore[no-redef]
9153
ROSActionGoalT = TypeVar("ROSActionGoalT", bound=ROSMessage)
9254
ROSActionResultT = TypeVar("ROSActionResultT", bound=ROSMessage)
9355
ROSActionFeedbackT = TypeVar("ROSActionFeedbackT", bound=ROSMessage)
94-
95-
try:
96-
from rosidl_pycommon.interface_base_classes import BaseImpl
97-
98-
ROSActionImplT = TypeVar("ROSActionImplT", bound=BaseImpl[Any, Any, Any])
99-
100-
ActionClientType = _ActionClient[
101-
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT, ROSActionImplT
102-
]
103-
ClientGoalHandleType = _ClientGoalHandle[
104-
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT, ROSActionImplT
105-
]
106-
ActionServerType = _ActionServer[
107-
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT, ROSActionImplT
108-
]
109-
ServerGoalHandleType = _ServerGoalHandle[
110-
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT, ROSActionImplT
111-
]
112-
113-
except ImportError:
114-
# Fallback to old type variables if BaseImpl is not available
115-
# TODO: Remove this fallback once we drop support for Kilted
116-
117-
ROSActionImplT = TypeVar("ROSActionImplT") # type: ignore[misc]
118-
119-
ActionClientType = _ActionClient[ # type: ignore[misc]
120-
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT
121-
]
122-
ClientGoalHandleType = _ClientGoalHandle[ # type: ignore[misc]
123-
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT
124-
]
125-
ActionServerType = _ActionServer[ # type: ignore[misc]
126-
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT
127-
]
128-
ServerGoalHandleType = _ServerGoalHandle[ # type: ignore[misc]
129-
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT
130-
]
56+
ROSActionImplT = TypeVar("ROSActionImplT", bound=BaseImpl[Any, Any, Any])
57+
58+
ActionClientType: TypeAlias = _ActionClient[
59+
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT, ROSActionImplT
60+
]
61+
ClientGoalHandleType: TypeAlias = _ClientGoalHandle[
62+
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT, ROSActionImplT
63+
]
64+
ActionServerType: TypeAlias = _ActionServer[
65+
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT, ROSActionImplT
66+
]
67+
ServerGoalHandleType: TypeAlias = _ServerGoalHandle[
68+
ROSActionGoalT, ROSActionResultT, ROSActionFeedbackT, ROSActionImplT
69+
]

0 commit comments

Comments
 (0)