Skip to content

Commit

Permalink
type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Feb 2, 2024
1 parent 3cf4d67 commit 89be209
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions spinnman/board_test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions spinnman/messages/eieio/command_messages/eieio_command_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 89be209

Please sign in to comment.