Skip to content

Commit 587e4cc

Browse files
authored
remove all deprecated classes and methods (#1456)
Signed-off-by: Tomoya Fujita <[email protected]>
1 parent 3414456 commit 587e4cc

File tree

9 files changed

+19
-170
lines changed

9 files changed

+19
-170
lines changed

rclpy/rclpy/action/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ async def _execute_goal_request(
367367
# Catch the exception here and go on so we don't crash.
368368
self._handle.send_goal_response(request_header, response_msg)
369369
except RCLError:
370-
self._logger.warn('Failed to send goal response (the client may have gone away)')
370+
self._logger.warning('Failed to send goal response (the client may have gone away)')
371371
return
372372

373373
if not accepted:
@@ -457,7 +457,7 @@ async def _execute_cancel_request(
457457
# Catch the exception here and go on so we don't crash.
458458
self._handle.send_cancel_response(request_header, cancel_response)
459459
except RCLError:
460-
self._logger.warn('Failed to send cancel response (the client may have gone away)')
460+
self._logger.warning('Failed to send cancel response (the client may have gone away)')
461461

462462
async def _execute_get_result_request(
463463
self,
@@ -472,7 +472,7 @@ async def _execute_get_result_request(
472472
# If no goal with the requested ID exists, then return UNKNOWN status
473473
# or the goal with the requested ID has been already expired
474474
if bytes(goal_uuid) not in self._goal_handles:
475-
self._logger.warn(
475+
self._logger.warning(
476476
'Sending result response for unknown or expired goal ID: {0}'.format(goal_uuid))
477477
result_response = self._action_type.Impl.GetResultService.Response()
478478
result_response.status = GoalStatus.STATUS_UNKNOWN

rclpy/rclpy/event_handler.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from typing import overload
2323
from typing import Type
2424
from typing import Union
25-
import warnings
2625

2726
import rclpy
2827
from rclpy.callback_groups import CallbackGroup
@@ -31,7 +30,6 @@
3130
from rclpy.qos import qos_policy_name_from_kind
3231
from rclpy.waitable import NumberOfEntities
3332
from rclpy.waitable import Waitable
34-
from typing_extensions import deprecated
3533
from typing_extensions import TypeAlias
3634

3735

@@ -184,16 +182,6 @@ def destroy(self) -> None:
184182
self.__event.destroy_when_not_in_use()
185183

186184

187-
@deprecated('QoSEventHandler foo is deprecated, use EventHandler instead.',
188-
category=DeprecationWarning, stacklevel=2)
189-
class QoSEventHandler(EventHandler):
190-
191-
def __init__(self, *args: Any, **kwargs: Any) -> None:
192-
warnings.warn('QoSEventHandler is deprecated, use EventHandler instead.',
193-
DeprecationWarning, stacklevel=2)
194-
super().__init__(*args, **kwargs)
195-
196-
197185
class SubscriptionEventCallbacks:
198186
"""Container to provide middleware event callbacks for a Subscription."""
199187

@@ -254,7 +242,7 @@ def create_event_handlers(
254242
# Register default callback when not specified
255243
def _default_incompatible_qos_callback(event: QoSRequestedIncompatibleQoSInfo) -> None:
256244
policy_name = qos_policy_name_from_kind(event.last_policy_kind)
257-
logger.warn(
245+
logger.warning(
258246
"New publisher discovered on topic '{}', offering incompatible QoS. "
259247
'No messages will be received from it. '
260248
'Last incompatible policy: {}'.format(topic_name, policy_name))
@@ -290,7 +278,7 @@ def _default_incompatible_qos_callback(event: QoSRequestedIncompatibleQoSInfo) -
290278
elif self.use_default_callbacks:
291279
# Register default callback when not specified
292280
def _default_incompatible_type_callback(event: Any) -> None:
293-
logger.warn(
281+
logger.warning(
294282
"Incompatible type on topic '{}', no messages will be sent to it."
295283
.format(topic_name))
296284
incompatible_type_callback = _default_incompatible_type_callback
@@ -379,7 +367,7 @@ def create_event_handlers(
379367
# Register default callback when not specified
380368
def _default_incompatible_qos_callback(event: QoSRequestedIncompatibleQoSInfo) -> None:
381369
policy_name = qos_policy_name_from_kind(event.last_policy_kind)
382-
logger.warn(
370+
logger.warning(
383371
"New subscription discovered on topic '{}', requesting incompatible QoS. "
384372
'No messages will be sent to it. '
385373
'Last incompatible policy: {}'.format(topic_name, policy_name))
@@ -401,7 +389,7 @@ def _default_incompatible_qos_callback(event: QoSRequestedIncompatibleQoSInfo) -
401389
elif self.use_default_callbacks:
402390
# Register default callback when not specified
403391
def _default_incompatible_type_callback(event: Any) -> None:
404-
logger.warn(
392+
logger.warning(
405393
"Incompatible type on topic '{}', no messages will be sent to it."
406394
.format(topic_name))
407395
incompatible_type_callback = _default_incompatible_type_callback

rclpy/rclpy/impl/rcutils_logger.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from rclpy.clock import Clock
3232
from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
3333
from rclpy.impl.logging_severity import LoggingSeverity
34-
from typing_extensions import deprecated, Unpack
34+
from typing_extensions import Unpack
3535

3636

3737
SupportedFiltersKeys = Literal['throttle', 'skip_first', 'once']
@@ -423,15 +423,6 @@ def warning(self, message: str, **kwargs: 'Unpack[LoggingArgs]') -> bool:
423423
"""Log a message with `WARN` severity via :py:classmethod:RcutilsLogger.log:."""
424424
return self.log(message, LoggingSeverity.WARN, **kwargs)
425425

426-
@deprecated('Deprecated in favor of :py:classmethod:RcutilsLogger.warning:.')
427-
def warn(self, message: str, **kwargs: 'Unpack[LoggingArgs]') -> bool:
428-
"""
429-
Log a message with `WARN` severity via :py:classmethod:RcutilsLogger.log:.
430-
431-
Deprecated in favor of :py:classmethod:RcutilsLogger.warning:.
432-
"""
433-
return self.warning(message, **kwargs)
434-
435426
def error(self, message: str, **kwargs: 'Unpack[LoggingArgs]') -> bool:
436427
"""Log a message with `ERROR` severity via :py:classmethod:RcutilsLogger.log:."""
437428
return self.log(message, LoggingSeverity.ERROR, **kwargs)

rclpy/rclpy/node.py

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
from rclpy.validate_parameter_name import validate_parameter_name
102102
from rclpy.validate_topic_name import validate_topic_name
103103
from rclpy.waitable import Waitable
104-
from typing_extensions import deprecated
105104
from typing_extensions import TypeAlias
106105

107106

@@ -388,18 +387,6 @@ def declare_parameter(self, name: str, value: Union[AllowableParameterValueT,
388387
ignore_override: bool = False
389388
) -> Parameter[AllowableParameterValueT]: ...
390389

391-
@overload
392-
@deprecated('when declaring a parameter only providing its name is deprecated. '
393-
'You have to either:\n'
394-
'\t- Pass a name and a default value different to "PARAMETER NOT SET"'
395-
' (and optionally a descriptor).\n'
396-
'\t- Pass a name and a parameter type.\n'
397-
'\t- Pass a name and a descriptor with `dynamic_typing=True')
398-
def declare_parameter(self, name: str,
399-
value: None = None,
400-
descriptor: None = None,
401-
ignore_override: bool = False) -> Parameter[Any]: ...
402-
403390
@overload
404391
def declare_parameter(self, name: str,
405392
value: Union[None, Parameter.Type, ParameterValue] = None,
@@ -455,29 +442,10 @@ def declare_parameters(
455442
ignore_override: bool = False
456443
) -> List[Parameter[Any]]: ...
457444

458-
@overload
459-
@deprecated('when declaring a parameter only providing its name is deprecated. '
460-
'You have to either:\n'
461-
'\t- Pass a name and a default value different to "PARAMETER NOT SET"'
462-
' (and optionally a descriptor).\n'
463-
'\t- Pass a name and a parameter type.\n'
464-
'\t- Pass a name and a descriptor with `dynamic_typing=True')
465-
def declare_parameters(
466-
self,
467-
namespace: str,
468-
parameters: Sequence[Union[
469-
Tuple[str],
470-
Tuple[str, ParameterInput],
471-
Tuple[str, ParameterInput, ParameterDescriptor],
472-
]],
473-
ignore_override: bool = False
474-
) -> List[Parameter[Any]]: ...
475-
476445
def declare_parameters(
477446
self,
478447
namespace: str,
479448
parameters: Union[Sequence[Union[
480-
Tuple[str],
481449
Tuple[str, ParameterInput],
482450
Tuple[str, ParameterInput, ParameterDescriptor]]],
483451
Sequence[Union[
@@ -565,15 +533,14 @@ def declare_parameters(
565533
)
566534

567535
if len(parameter_tuple) == 1:
568-
warnings.warn(
536+
raise TypeError(
569537
f"when declaring parameter named '{name}', "
570-
'declaring a parameter only providing its name is deprecated. '
538+
'declaring a parameter only providing its name is not allowed. '
571539
'You have to either:\n'
572540
'\t- Pass a name and a default value different to "PARAMETER NOT SET"'
573541
' (and optionally a descriptor).\n'
574542
'\t- Pass a name and a parameter type.\n'
575543
'\t- Pass a name and a descriptor with `dynamic_typing=True')
576-
descriptor.dynamic_typing = True
577544

578545
if isinstance(second_arg, Parameter.Type):
579546
if second_arg == Parameter.Type.NOT_SET:

rclpy/rclpy/qos.py

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
# limitations under the License.
1414

1515
from enum import Enum, IntEnum
16-
from typing import (Any, Callable, Iterable, List, Optional, Tuple, Type,
17-
TypeVar, Union)
16+
from typing import (Any, List, Optional, Tuple, TypeVar, Union)
1817
import warnings
1918

2019
from rclpy.duration import Duration
@@ -315,41 +314,6 @@ def short_key(self) -> str:
315314
_T = TypeVar('_T', bound=QoSPolicyEnum)
316315

317316

318-
class _DeprecatedPolicyValueAlias:
319-
"""Helper to deprecate a policy value."""
320-
321-
def __init__(self, replacement_name: str, deprecated_name: str) -> None:
322-
self.replacement_name = replacement_name
323-
self.deprecated_name = deprecated_name
324-
325-
def __get__(self, obj: object,
326-
policy_cls: Type[_T]) -> _T:
327-
warnings.warn(
328-
f'{policy_cls.__name__}.{self.deprecated_name} is deprecated. '
329-
f'Use {policy_cls.__name__}.{self.replacement_name} instead.'
330-
)
331-
return policy_cls[self.replacement_name]
332-
333-
334-
def _deprecated_policy_value_aliases(pairs: Iterable[Tuple[str, str]]) \
335-
-> Callable[[Type[_T]], Type[_T]]:
336-
def decorator(policy_cls: Type[_T]) -> Type[_T]:
337-
for deprecated_name, replacement_name in pairs:
338-
setattr(
339-
policy_cls,
340-
deprecated_name,
341-
_DeprecatedPolicyValueAlias(replacement_name, deprecated_name)
342-
)
343-
return policy_cls
344-
return decorator
345-
346-
347-
@_deprecated_policy_value_aliases((
348-
('RMW_QOS_POLICY_HISTORY_SYSTEM_DEFAULT', 'SYSTEM_DEFAULT'),
349-
('RMW_QOS_POLICY_HISTORY_KEEP_LAST', 'KEEP_LAST'),
350-
('RMW_QOS_POLICY_HISTORY_KEEP_ALL', 'KEEP_ALL'),
351-
('RMW_QOS_POLICY_HISTORY_UNKNOWN', 'UNKNOWN'),
352-
))
353317
class HistoryPolicy(QoSPolicyEnum):
354318
"""
355319
Enum for QoS History settings.
@@ -367,12 +331,6 @@ class HistoryPolicy(QoSPolicyEnum):
367331
QoSHistoryPolicy: TypeAlias = HistoryPolicy
368332

369333

370-
@_deprecated_policy_value_aliases((
371-
('RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT', 'SYSTEM_DEFAULT'),
372-
('RMW_QOS_POLICY_RELIABILITY_RELIABLE', 'RELIABLE'),
373-
('RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT', 'BEST_EFFORT'),
374-
('RMW_QOS_POLICY_RELIABILITY_UNKNOWN', 'UNKNOWN'),
375-
))
376334
class ReliabilityPolicy(QoSPolicyEnum):
377335
"""
378336
Enum for QoS Reliability settings.
@@ -391,12 +349,6 @@ class ReliabilityPolicy(QoSPolicyEnum):
391349
QoSReliabilityPolicy: TypeAlias = ReliabilityPolicy
392350

393351

394-
@_deprecated_policy_value_aliases((
395-
('RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT', 'SYSTEM_DEFAULT'),
396-
('RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL', 'TRANSIENT_LOCAL'),
397-
('RMW_QOS_POLICY_DURABILITY_VOLATILE', 'VOLATILE'),
398-
('RMW_QOS_POLICY_DURABILITY_UNKNOWN', 'UNKNOWN'),
399-
))
400352
class DurabilityPolicy(QoSPolicyEnum):
401353
"""
402354
Enum for QoS Durability settings.
@@ -415,12 +367,6 @@ class DurabilityPolicy(QoSPolicyEnum):
415367
QoSDurabilityPolicy: TypeAlias = DurabilityPolicy
416368

417369

418-
@_deprecated_policy_value_aliases((
419-
('RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT', 'SYSTEM_DEFAULT'),
420-
('RMW_QOS_POLICY_LIVELINESS_AUTOMATIC', 'AUTOMATIC'),
421-
('RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC', 'MANUAL_BY_TOPIC'),
422-
('RMW_QOS_POLICY_DURABILITY_UNKNOWN', 'UNKNOWN'),
423-
))
424370
class LivelinessPolicy(QoSPolicyEnum):
425371
"""
426372
Enum for QoS Liveliness settings.

rclpy/rclpy/qos_event.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

rclpy/src/rclpy/events_executor/events_executor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ void EventsExecutor::HandleCallbackExceptionWithLogger(
877877
R"(
878878
import traceback
879879
logger.fatal(f"Exception in '{node_entity_attr}' callback: {exc_value}")
880-
logger.warn("Error occurred at:\n" + "".join(traceback.format_tb(exc_trace)))
880+
logger.warning("Error occurred at:\n" + "".join(traceback.format_tb(exc_trace)))
881881
)",
882882
scope);
883883
}

0 commit comments

Comments
 (0)