From 68cce0306e2457192a92feefdf605319939bc61c Mon Sep 17 00:00:00 2001 From: Alex Ruddick Date: Thu, 8 Aug 2024 09:04:29 -0500 Subject: [PATCH 1/4] Fix type hint for ReactiveServer --- pymodbus_repl/server/cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pymodbus_repl/server/cli.py b/pymodbus_repl/server/cli.py index eade60c..06810be 100644 --- a/pymodbus_repl/server/cli.py +++ b/pymodbus_repl/server/cli.py @@ -17,6 +17,9 @@ from pymodbus_repl import __VERSION__ as repl_version from pymodbus_repl.lib.completer import CmdCompleter from pymodbus_repl.lib.helper import Command, style +from pymodbus_repl.lib.reactive import ( + ReactiveServer, +) TITLE = r""" @@ -167,7 +170,7 @@ def _print_help(): _print_help() -def print_server_config(server: "ReactiveServer", print_server_context: bool = False, *extra) -> dict: # noqa +def print_server_config(server: ReactiveServer, print_server_context: bool = False, *extra) -> dict: """Print server config.""" print_formatted_text() print_formatted_text(HTML("Server Configs:")) From 2652dafa383627bba51a731cf206f8bf9da8871f Mon Sep 17 00:00:00 2001 From: Alex Ruddick Date: Thu, 8 Aug 2024 09:05:49 -0500 Subject: [PATCH 2/4] Update ruff --- poetry.lock | 41 +++++++++++++++++++++-------------------- pyproject.toml | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/poetry.lock b/poetry.lock index f11877b..571be97 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "aiohttp" @@ -1134,28 +1134,29 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "ruff" -version = "0.2.1" +version = "0.5.6" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:dd81b911d28925e7e8b323e8d06951554655021df8dd4ac3045d7212ac4ba080"}, - {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:dc586724a95b7d980aa17f671e173df00f0a2eef23f8babbeee663229a938fec"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c92db7101ef5bfc18e96777ed7bc7c822d545fa5977e90a585accac43d22f18a"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:13471684694d41ae0f1e8e3a7497e14cd57ccb7dd72ae08d56a159d6c9c3e30e"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a11567e20ea39d1f51aebd778685582d4c56ccb082c1161ffc10f79bebe6df35"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:00a818e2db63659570403e44383ab03c529c2b9678ba4ba6c105af7854008105"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:be60592f9d218b52f03384d1325efa9d3b41e4c4d55ea022cd548547cc42cd2b"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fbd2288890b88e8aab4499e55148805b58ec711053588cc2f0196a44f6e3d855"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3ef052283da7dec1987bba8d8733051c2325654641dfe5877a4022108098683"}, - {file = "ruff-0.2.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:7022d66366d6fded4ba3889f73cd791c2d5621b2ccf34befc752cb0df70f5fad"}, - {file = "ruff-0.2.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0a725823cb2a3f08ee743a534cb6935727d9e47409e4ad72c10a3faf042ad5ba"}, - {file = "ruff-0.2.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:0034d5b6323e6e8fe91b2a1e55b02d92d0b582d2953a2b37a67a2d7dedbb7acc"}, - {file = "ruff-0.2.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e5cb5526d69bb9143c2e4d2a115d08ffca3d8e0fddc84925a7b54931c96f5c02"}, - {file = "ruff-0.2.1-py3-none-win32.whl", hash = "sha256:6b95ac9ce49b4fb390634d46d6ece32ace3acdd52814671ccaf20b7f60adb232"}, - {file = "ruff-0.2.1-py3-none-win_amd64.whl", hash = "sha256:e3affdcbc2afb6f5bd0eb3130139ceedc5e3f28d206fe49f63073cb9e65988e0"}, - {file = "ruff-0.2.1-py3-none-win_arm64.whl", hash = "sha256:efababa8e12330aa94a53e90a81eb6e2d55f348bc2e71adbf17d9cad23c03ee6"}, - {file = "ruff-0.2.1.tar.gz", hash = "sha256:3b42b5d8677cd0c72b99fcaf068ffc62abb5a19e71b4a3b9cfa50658a0af02f1"}, + {file = "ruff-0.5.6-py3-none-linux_armv6l.whl", hash = "sha256:a0ef5930799a05522985b9cec8290b185952f3fcd86c1772c3bdbd732667fdcd"}, + {file = "ruff-0.5.6-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b652dc14f6ef5d1552821e006f747802cc32d98d5509349e168f6bf0ee9f8f42"}, + {file = "ruff-0.5.6-py3-none-macosx_11_0_arm64.whl", hash = "sha256:80521b88d26a45e871f31e4b88938fd87db7011bb961d8afd2664982dfc3641a"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d9bc8f328a9f1309ae80e4d392836e7dbc77303b38ed4a7112699e63d3b066ab"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4d394940f61f7720ad371ddedf14722ee1d6250fd8d020f5ea5a86e7be217daf"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:111a99cdb02f69ddb2571e2756e017a1496c2c3a2aeefe7b988ddab38b416d36"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:e395daba77a79f6dc0d07311f94cc0560375ca20c06f354c7c99af3bf4560c5d"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c476acb43c3c51e3c614a2e878ee1589655fa02dab19fe2db0423a06d6a5b1b6"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e2ff8003f5252fd68425fd53d27c1f08b201d7ed714bb31a55c9ac1d4c13e2eb"}, + {file = "ruff-0.5.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c94e084ba3eaa80c2172918c2ca2eb2230c3f15925f4ed8b6297260c6ef179ad"}, + {file = "ruff-0.5.6-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1f77c1c3aa0669fb230b06fb24ffa3e879391a3ba3f15e3d633a752da5a3e670"}, + {file = "ruff-0.5.6-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:f908148c93c02873210a52cad75a6eda856b2cbb72250370ce3afef6fb99b1ed"}, + {file = "ruff-0.5.6-py3-none-musllinux_1_2_i686.whl", hash = "sha256:563a7ae61ad284187d3071d9041c08019975693ff655438d8d4be26e492760bd"}, + {file = "ruff-0.5.6-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:94fe60869bfbf0521e04fd62b74cbca21cbc5beb67cbb75ab33fe8c174f54414"}, + {file = "ruff-0.5.6-py3-none-win32.whl", hash = "sha256:e6a584c1de6f8591c2570e171cc7ce482bb983d49c70ddf014393cd39e9dfaed"}, + {file = "ruff-0.5.6-py3-none-win_amd64.whl", hash = "sha256:d7fe7dccb1a89dc66785d7aa0ac283b2269712d8ed19c63af908fdccca5ccc1a"}, + {file = "ruff-0.5.6-py3-none-win_arm64.whl", hash = "sha256:57c6c0dd997b31b536bff49b9eee5ed3194d60605a4427f735eeb1f9c1b8d264"}, + {file = "ruff-0.5.6.tar.gz", hash = "sha256:07c9e3c2a8e1fe377dd460371c3462671a728c981c3205a5217291422209f642"}, ] [[package]] @@ -1415,4 +1416,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "beff35ee0da3d7b488e1b75610b3f8bc5e85e91b22e10c0384bde20ed8a6fea0" +content-hash = "fb9ca3a4f118a674780e557c240b2d8e166b2bcee217d65155c09682b1352b50" diff --git a/pyproject.toml b/pyproject.toml index 140bc92..22048b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ include = ["pymodbus_repl"] [tool.poetry.group.dev.dependencies] pymodbus = {git = "https://github.com/pymodbus-dev/pymodbus", rev = "dev"} -ruff = "^0.2.1" +ruff = "^0.5.6" coverage = "^7.4.1" pytest-xdist = "^3.5.0" pytest-cov = "^4.1.0" From f37fb769a5af0c1bd62555e1cfc22da26c453abd Mon Sep 17 00:00:00 2001 From: Alex Ruddick Date: Thu, 8 Aug 2024 09:38:56 -0500 Subject: [PATCH 3/4] fix mypy errors --- pymodbus_repl/lib/helper.py | 2 +- pymodbus_repl/server/cli.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pymodbus_repl/lib/helper.py b/pymodbus_repl/lib/helper.py index 8d990ec..88b457f 100644 --- a/pymodbus_repl/lib/helper.py +++ b/pymodbus_repl/lib/helper.py @@ -74,7 +74,7 @@ ) -class Command: +class Command(dict): """Class representing Commands to be consumed by Completer.""" def __init__(self, name, signature, doc, slave=False): diff --git a/pymodbus_repl/server/cli.py b/pymodbus_repl/server/cli.py index 06810be..3730272 100644 --- a/pymodbus_repl/server/cli.py +++ b/pymodbus_repl/server/cli.py @@ -170,7 +170,7 @@ def _print_help(): _print_help() -def print_server_config(server: ReactiveServer, print_server_context: bool = False, *extra) -> dict: +def print_server_config(server: ReactiveServer, print_server_context: bool = False, *extra): """Print server config.""" print_formatted_text() print_formatted_text(HTML("Server Configs:")) From e8c52056b3d7c728d2e12a34c1fa933e5e6a7734 Mon Sep 17 00:00:00 2001 From: Alex Ruddick Date: Thu, 8 Aug 2024 10:21:36 -0500 Subject: [PATCH 4/4] use more explicit type hint for COMMANDS --- pymodbus_repl/lib/helper.py | 2 +- pymodbus_repl/server/cli.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pymodbus_repl/lib/helper.py b/pymodbus_repl/lib/helper.py index 88b457f..8d990ec 100644 --- a/pymodbus_repl/lib/helper.py +++ b/pymodbus_repl/lib/helper.py @@ -74,7 +74,7 @@ ) -class Command(dict): +class Command: """Class representing Commands to be consumed by Completer.""" def __init__(self, name, signature, doc, slave=False): diff --git a/pymodbus_repl/server/cli.py b/pymodbus_repl/server/cli.py index 3730272..b5d2451 100644 --- a/pymodbus_repl/server/cli.py +++ b/pymodbus_repl/server/cli.py @@ -3,7 +3,7 @@ import inspect import shutil from collections import defaultdict -from typing import Optional +from typing import Dict, Optional import click from prompt_toolkit import PromptSession, print_formatted_text @@ -40,7 +40,7 @@ ) COMMAND_ARGS = ["response_type", "error_code", "delay_by", "clear_after", "data_len"] RESPONSE_TYPES = ["normal", "error", "delayed", "empty", "stray"] -COMMANDS = { +COMMANDS: Dict[str, Optional[Dict | Command]] = { "manipulator": { "response_type": None, "error_code": None,