missing explicit function return types added

This commit is contained in:
Nicolas 2025-04-12 11:10:35 +02:00
parent 61f431a534
commit 96c716b1c5
3 changed files with 7 additions and 7 deletions

View File

@ -41,7 +41,7 @@ class BusTerminal():
self._mixed_mapping = mixed_mapping self._mixed_mapping = mixed_mapping
@classmethod @classmethod
def select(cls, bus_coupler: 'BusCoupler', terminal_number: int = 0): def select(cls, bus_coupler: 'BusCoupler', terminal_number: int = 0) -> 'BusTerminal':
terminal_list = [bt for bt in bus_coupler.bus_terminals if isinstance(bt, cls)] terminal_list = [bt for bt in bus_coupler.bus_terminals if isinstance(bt, cls)]
assert terminal_list, f'No instance of {cls.__name__} configured at this BusCoupler' assert terminal_list, f'No instance of {cls.__name__} configured at this BusCoupler'
assert 0 <= terminal_number < len(terminal_list), f'Out of range, select in range: 0..{len(terminal_list) - 1}' assert 0 <= terminal_number < len(terminal_list), f'Out of range, select in range: 0..{len(terminal_list) - 1}'
@ -247,7 +247,7 @@ class BusCoupler():
self.add_bus_terminals(bus_terminals) self.add_bus_terminals(bus_terminals)
self._init_hardware(watchdog) self._init_hardware(watchdog)
def _init_hardware(self, watchdog: float): def _init_hardware(self, watchdog: float) -> None:
pass pass
def add_bus_terminals(self, *new_bus_terminals: Type[BusTerminal] | Iterable[Type[BusTerminal]]) -> list[BusTerminal]: def add_bus_terminals(self, *new_bus_terminals: Type[BusTerminal] | Iterable[Type[BusTerminal]]) -> list[BusTerminal]:
@ -272,7 +272,7 @@ class BusCoupler():
for terminal_class in terminal_classes: for terminal_class in terminal_classes:
assert _is_bus_terminal(terminal_class), f'{terminal_class} is not a bus terminal' assert _is_bus_terminal(terminal_class), f'{terminal_class} is not a bus terminal'
def get_para(key: str): def get_para(key: str) -> int:
return terminal_class.parameters.get(key, 0) return terminal_class.parameters.get(key, 0)
new_terminal = terminal_class( new_terminal = terminal_class(

View File

@ -7,7 +7,7 @@ class BK9000(BusCoupler):
""" """
BK9000 ModBus TCP bus coupler BK9000 ModBus TCP bus coupler
""" """
def _init_hardware(self, watchdog: float): def _init_hardware(self, watchdog: float) -> None:
# https://download.beckhoff.com/download/document/io/bus-terminals/bk9000_bk9050_bk9100de.pdf # https://download.beckhoff.com/download/document/io/bus-terminals/bk9000_bk9050_bk9100de.pdf
# config watchdog on page 58 # config watchdog on page 58
@ -44,7 +44,7 @@ class WAGO_750_352(BusCoupler):
""" """
Wago 750-352 ModBus TCP bus coupler Wago 750-352 ModBus TCP bus coupler
""" """
def _init_hardware(self, watchdog: float): def _init_hardware(self, watchdog: float) -> None:
# deactivate/reset watchdog timer: # deactivate/reset watchdog timer:
self.modbus.write_single_register(0x1005, 0xAAAA) self.modbus.write_single_register(0x1005, 0xAAAA)
self.modbus.write_single_register(0x1005, 0x5555) self.modbus.write_single_register(0x1005, 0x5555)

View File

@ -87,7 +87,7 @@ class SimpleModbusClient:
self._socket: None | socket.socket = None self._socket: None | socket.socket = None
self.debug = debug self.debug = debug
def connect(self): def connect(self) -> bool:
for af, st, pr, _, sa in socket.getaddrinfo(self.host, self.port, for af, st, pr, _, sa in socket.getaddrinfo(self.host, self.port,
socket.AF_UNSPEC, socket.AF_UNSPEC,
socket.SOCK_STREAM): socket.SOCK_STREAM):
@ -110,7 +110,7 @@ class SimpleModbusClient:
self.last_error = 'connection failed' self.last_error = 'connection failed'
return False return False
def close(self): def close(self) -> bytes:
""" """
Close connection Close connection