Skip to content

Commit

Permalink
Changed type hints in ros_loader.py to use imports from Typing (backp…
Browse files Browse the repository at this point in the history
…ort #938)
  • Loading branch information
EricGallimore authored and sea-bass committed Oct 3, 2024
1 parent 9f45b8e commit 7fb49c5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions rosbridge_library/src/rosbridge_library/internal/ros_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import importlib
from threading import Lock
from typing import Any
from typing import Any, Dict, Tuple

""" ros_loader contains methods for dynamically loading ROS message classes at
runtime. It's achieved by using roslib to load the manifest files for the
Expand Down Expand Up @@ -129,7 +129,7 @@ def get_action_result_instance(typestring: str) -> Any:


def _get_interface_class(
typestring: str, intf_type: str, loaded_intfs: dict[str, Any], intf_lock: Lock
typestring: str, intf_type: str, loaded_intfs: Dict[str, Any], intf_lock: Lock
) -> Any:
"""
If not loaded, loads the specified ROS interface class then returns an instance of it.
Expand All @@ -152,7 +152,7 @@ def _get_interface_class(
return _get_class(typestring, intf_type, loaded_intfs, intf_lock)


def _get_class(typestring: str, subname: str, cache: dict[str, Any], lock: Lock) -> Any:
def _get_class(typestring: str, subname: str, cache: Dict[str, Any], lock: Lock) -> Any:
"""If not loaded, loads the specified class then returns an instance
of it.
Expand Down Expand Up @@ -206,7 +206,7 @@ def _load_class(modname: str, subname: str, classname: str) -> None:
raise InvalidClassException(modname, subname, classname, exc)


def _splittype(typestring: str) -> tuple[str, str]:
def _splittype(typestring: str) -> Tuple[str, str]:
"""Split the string the / delimiter and strip out empty strings
Performs similar logic to roslib.names.package_resource_name but is a bit
Expand All @@ -220,13 +220,13 @@ def _splittype(typestring: str) -> tuple[str, str]:
raise InvalidTypeStringException(typestring)


def _add_to_cache(cache: dict[str, Any], lock: Lock, key: str, value: any) -> None:
def _add_to_cache(cache: Dict[str, Any], lock: Lock, key: str, value: any) -> None:
lock.acquire()
cache[key] = value
lock.release()


def _get_from_cache(cache: dict[str, Any], lock: Lock, key: str) -> Any:
def _get_from_cache(cache: Dict[str, Any], lock: Lock, key: str) -> Any:
"""Returns the value for the specified key from the cache.
Locks the lock before doing anything. Returns None if key not in cache"""
lock.acquire()
Expand Down

0 comments on commit 7fb49c5

Please sign in to comment.