Skip to content

Commit

Permalink
Improve bdai_ros2_wrappers.utilities type annotations (#114)
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
mhidalgo-bdai authored Aug 14, 2024
1 parent 3c04b0d commit a7857a2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bdai_ros2_wrappers/bdai_ros2_wrappers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import threading
import warnings
from collections.abc import Mapping
from typing import Any, Callable, Iterator, List, Optional, Tuple
from typing import Any, Callable, Iterator, List, Optional, Tuple, TypeVar

import rclpy.clock
import rclpy.duration
Expand Down Expand Up @@ -482,7 +482,10 @@ def localized_error_message(user_message: Optional[str] = None) -> str:
return message


def ensure(value: Optional[Any]) -> Any:
T = TypeVar("T")


def ensure(value: Optional[T]) -> T:
"""Ensures `value` is not None or fails trying."""
if value is None:
raise ValueError(localized_error_message())
Expand Down

0 comments on commit a7857a2

Please sign in to comment.