From 5aab2d6d74a9a49118584ceb481d6f3e71c2c613 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 13 May 2025 09:39:05 +0200 Subject: [PATCH] Escaping for f-strings fixed --- .flake8 | 1 + src/pyhoff/__init__.py | 6 +++--- src/pyhoff/modbus.py | 6 +++--- tests/test_beckh_trace.py | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.flake8 b/.flake8 index 10c587e..eb1eb4f 100644 --- a/.flake8 +++ b/.flake8 @@ -14,6 +14,7 @@ exclude = dist, .conda .venv + venv # Enable specific plugins or options # Example: Enabling flake8-docstrings diff --git a/src/pyhoff/__init__.py b/src/pyhoff/__init__.py index 3d5dba1..43c1367 100644 --- a/src/pyhoff/__init__.py +++ b/src/pyhoff/__init__.py @@ -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) diff --git a/src/pyhoff/modbus.py b/src/pyhoff/modbus.py index fccc91a..5630649 100644 --- a/src/pyhoff/modbus.py +++ b/src/pyhoff/modbus.py @@ -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() diff --git a/tests/test_beckh_trace.py b/tests/test_beckh_trace.py index 74c5465..919cce7 100644 --- a/tests/test_beckh_trace.py +++ b/tests/test_beckh_trace.py @@ -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)