From 75725082349da6d345ee03776392b344611ae27d Mon Sep 17 00:00:00 2001 From: jan iversen Date: Sat, 7 Dec 2024 14:29:20 +0100 Subject: [PATCH] Pin python 3.13.0 and update ruff. (#2487) --- .github/workflows/ci.yml | 4 ++-- examples/message_parser.py | 32 +++++++------------------------- pymodbus/__init__.py | 2 +- pymodbus/datastore/__init__.py | 4 ++-- pymodbus/datastore/simulator.py | 2 +- pymodbus/device.py | 4 ++-- pymodbus/exceptions.py | 8 ++++---- pymodbus/framer/__init__.py | 6 +++--- pymodbus/server/__init__.py | 2 +- pymodbus/transport/__init__.py | 2 +- pyproject.toml | 4 ++-- 11 files changed, 26 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d782fef15..b25cce1ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,11 +36,11 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python: ['3.9', '3.10', '3.11', '3.12', "3.13"] + python: ['3.9', '3.10', '3.11', '3.12', "3.13.0"] include: - python: '3.9' run_lint: true - - python: '3.13' + - python: '3.13.0' run_doc: true run_lint: true - os: macos-latest diff --git a/examples/message_parser.py b/examples/message_parser.py index c022d8deb..312a27cc3 100755 --- a/examples/message_parser.py +++ b/examples/message_parser.py @@ -93,40 +93,22 @@ def check_errors(self, decoder, message): def report(self, message): """Print the message information.""" print( - "%-15s = %s" # pylint: disable=consider-using-f-string - % ( - "name", - message.__class__.__name__, - ) + f"{'name':.15s} = {message.__class__.__name__}" ) for k_dict, v_dict in message.__dict__.items(): if isinstance(v_dict, dict): - print("%-15s =" % k_dict) # pylint: disable=consider-using-f-string + print(f"{k_dict:.15s} =") for k_item, v_item in v_dict.items(): - print( - " %-12s => %s" # pylint: disable=consider-using-f-string - % (k_item, v_item) + print(f" {k_item:.12s} => {v_item}" ) elif isinstance(v_dict, collections.abc.Iterable): - print("%-15s =" % k_dict) # pylint: disable=consider-using-f-string + print(f"{k_dict:.15s} =") value = str([int(x) for x in v_dict]) for line in textwrap.wrap(value, 60): - print( - "%-15s . %s" # pylint: disable=consider-using-f-string - % ("", line) - ) + print(f"{' ':.15s} . {line}") else: - print( - "%-15s = %s" # pylint: disable=consider-using-f-string - % (k_dict, hex(v_dict)) - ) - print( - "%-15s = %s" # pylint: disable=consider-using-f-string - % ( - "documentation", - message.__doc__, - ) - ) + print(f"{k_dict:.15s} = {hex(v_dict)}") + print("{'documentation':.15s} = {message.__doc__}") # -------------------------------------------------------------------------- # diff --git a/pymodbus/__init__.py b/pymodbus/__init__.py index 017fb38ee..6d9f0fdaa 100644 --- a/pymodbus/__init__.py +++ b/pymodbus/__init__.py @@ -7,9 +7,9 @@ "ExceptionResponse", "FramerType", "ModbusException", - "pymodbus_apply_logging_config", "__version__", "__version_full__", + "pymodbus_apply_logging_config", ] from pymodbus.exceptions import ModbusException diff --git a/pymodbus/datastore/__init__.py b/pymodbus/datastore/__init__.py index e66600d7d..abd350601 100644 --- a/pymodbus/datastore/__init__.py +++ b/pymodbus/datastore/__init__.py @@ -3,10 +3,10 @@ __all__ = [ "ModbusBaseSlaveContext", "ModbusSequentialDataBlock", - "ModbusSparseDataBlock", - "ModbusSlaveContext", "ModbusServerContext", "ModbusSimulatorContext", + "ModbusSlaveContext", + "ModbusSparseDataBlock", ] from pymodbus.datastore.context import ( diff --git a/pymodbus/datastore/simulator.py b/pymodbus/datastore/simulator.py index 7c7d96e0c..4b1c3e611 100644 --- a/pymodbus/datastore/simulator.py +++ b/pymodbus/datastore/simulator.py @@ -542,7 +542,7 @@ def loop_validate(self, address, end_address, fx_write): i = address while i < end_address: reg = self.registers[i] - if fx_write and not reg.access or reg.type == CellType.INVALID: + if (fx_write and not reg.access) or reg.type == CellType.INVALID: return False if not self.type_exception: i += 1 diff --git a/pymodbus/device.py b/pymodbus/device.py index 7187b54ee..541369905 100644 --- a/pymodbus/device.py +++ b/pymodbus/device.py @@ -8,9 +8,9 @@ __all__ = [ - "ModbusPlusStatistics", - "ModbusDeviceIdentification", "DeviceInformationFactory", + "ModbusDeviceIdentification", + "ModbusPlusStatistics", ] import struct diff --git a/pymodbus/exceptions.py b/pymodbus/exceptions.py index b3238c276..7c685879b 100644 --- a/pymodbus/exceptions.py +++ b/pymodbus/exceptions.py @@ -4,13 +4,13 @@ """ __all__ = [ - "ModbusIOException", - "ParameterException", - "NotImplementedException", "ConnectionException", - "NoSuchSlaveException", "InvalidMessageReceivedException", "MessageRegisterException", + "ModbusIOException", + "NoSuchSlaveException", + "NotImplementedException", + "ParameterException", ] diff --git a/pymodbus/framer/__init__.py b/pymodbus/framer/__init__.py index aa40ccc92..17e7bed8d 100644 --- a/pymodbus/framer/__init__.py +++ b/pymodbus/framer/__init__.py @@ -1,11 +1,11 @@ """Framer.""" __all__ = [ - "FramerBase", - "FramerType", "FramerAscii", + "FramerBase", "FramerRTU", "FramerSocket", - "FramerTLS" + "FramerTLS", + "FramerType" ] from pymodbus.framer.ascii import FramerAscii diff --git a/pymodbus/server/__init__.py b/pymodbus/server/__init__.py index 2f7f52624..937f02386 100644 --- a/pymodbus/server/__init__.py +++ b/pymodbus/server/__init__.py @@ -4,7 +4,6 @@ """ __all__ = [ - "get_simulator_commandline", "ModbusSerialServer", "ModbusSimulatorServer", "ModbusTcpServer", @@ -20,6 +19,7 @@ "StartTcpServer", "StartTlsServer", "StartUdpServer", + "get_simulator_commandline", ] from pymodbus.server.async_io import ( diff --git a/pymodbus/transport/__init__.py b/pymodbus/transport/__init__.py index dd8ce04f9..caf7cd52a 100644 --- a/pymodbus/transport/__init__.py +++ b/pymodbus/transport/__init__.py @@ -1,9 +1,9 @@ """Transport.""" __all__ = [ + "NULLMODEM_HOST", "CommParams", "CommType", "ModbusProtocol", - "NULLMODEM_HOST", ] from pymodbus.transport.transport import ( diff --git a/pyproject.toml b/pyproject.toml index 72ac281ca..1159ef183 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,7 @@ repl = [ simulator = [ "aiohttp>=3.8.6;python_version<'3.12'", - "aiohttp>=3.10.5;python_version>='3.12'" + "aiohttp>=3.10.6;python_version>='3.12'" ] documentation = [ "recommonmark>=0.7.1", @@ -72,7 +72,7 @@ development = [ "pytest-timeout>=2.3.1", "pytest-xdist>=3.6.1", "pytest-aiohttp>=1.0.5", - "ruff>=0.5.3", + "ruff>=0.8.2", "twine>=5.1.1", "types-Pygments", "types-pyserial"