Skip to content

Commit

Permalink
Fixes from review.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed May 16, 2023
1 parent 936ea3c commit 7c15af1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ros2service/ros2service/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_service_class(node: Node, service_name: str, include_hidden_services: bo
:param service_name: The fully-qualified name of the service.
:param include_hidden_services: Whether to include hidden services while finding the
list of currently running services.
:return:
:return: the service class or None
"""
service_names_and_types = get_service_names_and_types(
node=node,
Expand All @@ -67,16 +67,16 @@ def get_service_class(node: Node, service_name: str, include_hidden_services: bo
if len(matched_names_and_types) < 1:
raise RuntimeError(f"Cannot find type for '{service_name}'")
if len(matched_names_and_types) > 1:
raise RuntimeError("Unexpectedly saw more than one entry for service'{service_name}'")
raise RuntimeError(f"Unexpectedly saw more than one entry for service '{service_name}'")

# Now check whether there are multiple types associated with this service, which is unsupported
service_name_and_types = matched_names_and_types[0]

types = service_name_and_types[1]
if len(types) < 1:
raise RuntimeError("No types associated with '{service_name}'")
raise RuntimeError(f"No types associated with '{service_name}'")
if len(types) > 1:
raise RuntimeError("More than one type associated with service '{service_name}'")
raise RuntimeError(f"More than one type associated with service '{service_name}'")

service_type = types[0]

Expand Down
2 changes: 1 addition & 1 deletion ros2service/ros2service/verb/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def main(self, *, args):
srv_module = get_service_class(
node, args.service_name, include_hidden_services=True)
except (AttributeError, ModuleNotFoundError, ValueError):
raise RuntimeError("The service name '%s' is invalid" % args.service_name)
raise RuntimeError(f"The service name '{args.service_name}' is invalid")
else:
try:
srv_module = get_service(args.service_type)
Expand Down

0 comments on commit 7c15af1

Please sign in to comment.