Skip to content

Commit

Permalink
Fix mypy and pylint errors (#14)
Browse files Browse the repository at this point in the history
* Fix mypy errors

* Fix pylint error
  • Loading branch information
bjsowa authored Nov 18, 2024
1 parent 76c20ac commit 98bf6cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions leo_fw/leo_fw/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def determine_board(node: rclpy.Node) -> Optional[BoardType]:
future = get_board_type.call_async(Trigger.Request())
rclpy.spin_until_future_complete(node, future, timeout_sec=5.0)
if future.done() and not future.exception():
result = future.result()
result: Trigger.Response | None = future.result()
assert result is not None
type_str = result.message
if type_str == str(BoardType.CORE2):
board_type = BoardType.CORE2
Expand All @@ -76,7 +77,8 @@ def check_firmware_version(node: rclpy.Node) -> str:
future = get_firmware_version.call_async(Trigger.Request())
rclpy.spin_until_future_complete(node, future, timeout_sec=5.0)
if future.done() and not future.exception():
result = future.result()
result: Trigger.Response | None = future.result()
assert result is not None
firmware_version = result.message
get_firmware_version.destroy()

Expand Down
9 changes: 7 additions & 2 deletions leo_fw/leo_fw/nodes/parameter_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,16 @@ def send_params(self) -> tuple[bool, int]:
param_request.parameters = self.parse_firmware_parameters()
future = self.firmware_parameter_service_client.call_async(param_request)

assert self.executor is not None
self.executor.spin_until_future_complete(future, 5.0)

if future.result():
set_params_response: SetParameters.Response | None = future.result()
if set_params_response is not None:
result: SetParametersResult
param: ParameterMsg
for result, param in zip(future.result().results, param_request.parameters):
for result, param in zip(
set_params_response.results, param_request.parameters
):
if not result.successful:
self.get_logger().warning(
f"Parameter '{param.name}' not set. Reason: '{result.reason}'"
Expand All @@ -234,6 +238,7 @@ def trigger_boot(self) -> bool:
boot_request = Trigger.Request()
boot_future = self.frimware_boot_service_client.call_async(boot_request)

assert self.executor is not None
self.executor.spin_until_future_complete(boot_future, 5.0)

if boot_future.result():
Expand Down
2 changes: 1 addition & 1 deletion leo_fw/leo_fw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def query_yes_no(question: str, default: str = "yes") -> bool:
return valid[default]
if choice in valid:
return valid[choice]
print("Please respond with 'yes' or 'no' " "(or 'y' or 'n').")
print("Please respond with 'yes' or 'no' (or 'y' or 'n').")


def prompt_options(options: list[tuple[str, T]], default: int = 1) -> T:
Expand Down

0 comments on commit 98bf6cd

Please sign in to comment.