Escaping for f-strings fixed

This commit is contained in:
Nicolas 2025-05-13 09:39:05 +02:00
parent d748553711
commit 5aab2d6d74
4 changed files with 8 additions and 7 deletions

View File

@ -14,6 +14,7 @@ exclude =
dist,
.conda
.venv
venv
# Enable specific plugins or options
# Example: Enabling flake8-docstrings

View File

@ -45,8 +45,8 @@ class BusTerminal():
@classmethod
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)]
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 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}"
return terminal_list[terminal_number]
@ -283,7 +283,7 @@ class BusCoupler():
terminal_classes.append(element)
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) -> int:
return terminal_class.parameters.get(key, 0)

View File

@ -451,7 +451,7 @@ class SimpleModbusClient:
return bytes()
if self.debug:
print(f'<- Received: {' '.join(hex(b) for b in buffer)}')
print(f"<- Received: {' '.join(hex(b) for b in buffer)}")
return buffer
@ -471,7 +471,7 @@ class SimpleModbusClient:
try:
self._socket.sendall(data)
if self.debug:
print(f'-> Send: {' '.join(hex(b) for b in data)}')
print(f"-> Send: {' '.join(hex(b) for b in data)}")
return len(data)
except socket.error:
self.last_error = 'sending data failed'
@ -532,7 +532,7 @@ class SimpleModbusClient:
return self.close()
if data[0] > 0x80:
self.last_error = f'return error: {_modbus_exceptions.get(data[1], '')} ({data[1]})'
self.last_error = f"return error: {_modbus_exceptions.get(data[1], '')} ({data[1]})"
if self.debug:
print(self.last_error)
return bytes()

View File

@ -14,7 +14,7 @@ def test_against_old_traces():
# dummy modbus send function
def debug_send_dummy(data: bytes) -> int:
print(f'-> Send: {' '.join(hex(b) for b in data)}')
print(f"-> Send: {' '.join(hex(b) for b in data)}")
for b in data:
debug_data.append(f"{b:02X}")
return len(data)