From 89be209c838edd416d29a27ac4789a93362c50a4 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 09:44:22 +0000 Subject: [PATCH] type fixes --- spinnman/board_test_configuration.py | 8 ++++---- .../udp_packet_connections/ip_address_connection.py | 6 +++--- .../eieio/command_messages/eieio_command_header.py | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/spinnman/board_test_configuration.py b/spinnman/board_test_configuration.py index 416c75df4..19ac94cd4 100644 --- a/spinnman/board_test_configuration.py +++ b/spinnman/board_test_configuration.py @@ -49,16 +49,16 @@ def set_up_remote_board(self, version: Optional[int] = None): """ if Ping.host_is_reachable("192.168.240.253"): self.remotehost = "192.168.240.253" - set_config("Machine", "version", 3) + set_config("Machine", "version", "3") self.auto_detect_bmp = False elif Ping.host_is_reachable("spinn-4.cs.man.ac.uk"): self.remotehost = "spinn-4.cs.man.ac.uk" - set_config("Machine", "version", 5) + set_config("Machine", "version", "5") elif Ping.host_is_reachable("192.168.240.1"): self.remotehost = "192.168.240.1" - set_config("Machine", "version", 5) + set_config("Machine", "version", "5") elif version is not None: self.remotehost = LOCAL_HOST - set_config("Machine", "version", version) + set_config("Machine", "version", str(version)) else: raise unittest.SkipTest("None of the test boards reachable") diff --git a/spinnman/connections/udp_packet_connections/ip_address_connection.py b/spinnman/connections/udp_packet_connections/ip_address_connection.py index 10788ac67..42b6ed142 100644 --- a/spinnman/connections/udp_packet_connections/ip_address_connection.py +++ b/spinnman/connections/udp_packet_connections/ip_address_connection.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from contextlib import suppress -from typing import Optional, Tuple +from typing import Optional from spinnman.constants import UDP_BOOT_CONNECTION_DEFAULT_PORT from .udp_connection import UDPConnection @@ -31,12 +31,12 @@ def __init__(self, local_host=None, super().__init__(local_host=local_host, local_port=local_port) def receive_ip_address(self, timeout: Optional[float] = None - ) -> Optional[Tuple[bytes, Tuple[str, int]]]: + ) -> Optional[str]: """ :param timeout: :type timeout: float or None - :rtype: tuple(byte, tuple(str, int)) or None + :rtype: str or None """ with suppress(Exception): (_, (ip_address, port)) = self.receive_with_address(timeout) diff --git a/spinnman/messages/eieio/command_messages/eieio_command_header.py b/spinnman/messages/eieio/command_messages/eieio_command_header.py index d5e96fecf..cb1c3c125 100644 --- a/spinnman/messages/eieio/command_messages/eieio_command_header.py +++ b/spinnman/messages/eieio/command_messages/eieio_command_header.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Union +from typing import cast, Union import struct from enum import Enum from spinnman.exceptions import SpinnmanInvalidParameterException @@ -33,12 +33,14 @@ def __init__(self, command: Union[int, Enum]): :type command: int or Enum """ if isinstance(command, Enum): - command = command.value - if command < 0 or command >= 16384: + command_value = command.value + else: + command_value = cast(int, command) + if command_value < 0 or command_value >= 16384: raise SpinnmanInvalidParameterException( "command", command, "parameter command is outside the allowed range (0 to 16383)") - self._command = command + self._command = command_value @property def command(self) -> int: