Skip to content

Commit

Permalink
from __future__ import annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 committed Sep 14, 2024
1 parent bccac91 commit d05af3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pymodbus_repl/client/mclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from pymodbus.client import ModbusSerialClient as _ModbusSerialClient
from pymodbus.client import ModbusTcpClient as _ModbusTcpClient
from pymodbus.client.base import ModbusBaseSyncClient as _ModbusBaseSyncClient
from pymodbus.exceptions import ModbusIOException
from pymodbus.pdu import ExceptionResponse, ModbusExceptions
from pymodbus.pdu.diag_message import (
ChangeAsciiInputDelimiterRequest,
ClearCountersRequest,
Expand All @@ -26,7 +28,6 @@
ReturnSlaveNAKCountRequest,
ReturnSlaveNoResponseCountRequest,
)
from pymodbus.exceptions import ModbusIOException
from pymodbus.pdu.mei_message import (
ReadDeviceInformationRequest,
ReadDeviceInformationResponse,
Expand All @@ -41,7 +42,6 @@
ReportSlaveIdRequest,
ReportSlaveIdResponse,
)
from pymodbus.pdu import ExceptionResponse, ModbusExceptions
from pymodbus.pdu.register_write_message import MaskWriteRegisterResponse


Expand Down
13 changes: 7 additions & 6 deletions pymodbus_repl/server/cli.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Repl server cli."""
from __future__ import annotations

import functools
import inspect
import shutil
from collections import defaultdict
from typing import Dict, Optional

import click
from prompt_toolkit import PromptSession, print_formatted_text
Expand Down Expand Up @@ -40,7 +41,7 @@
)
COMMAND_ARGS = ["response_type", "error_code", "delay_by", "clear_after", "data_len"]
RESPONSE_TYPES = ["normal", "error", "delayed", "empty", "stray"]
COMMANDS: Dict[str, Optional[Dict | Command]] = {
COMMANDS: dict[str, dict | Command | None] = {
"manipulator": {
"response_type": None,
"error_code": None,
Expand Down Expand Up @@ -78,9 +79,9 @@
}


def manipulator_to_dict(response_type: str = 'normal', error_code: Optional[int] = None,
delay_by: Optional[float] = None,
clear_after: Optional[int] = None) -> dict:
def manipulator_to_dict(response_type: str = 'normal', error_code: int | None = None,
delay_by: float | None = None,
clear_after: int | None = None) -> dict:
"""
Manipulate response from the server.
Expand Down Expand Up @@ -147,7 +148,7 @@ def get_terminal_width():
return shutil.get_terminal_size()[0]


def print_help(command: Optional[str] = None):
def print_help(command: str | None = None):
"""Print help."""

def _print_formatted(cmd: str, hlp: str):
Expand Down
2 changes: 1 addition & 1 deletion pymodbus_repl/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import typer
from pymodbus import pymodbus_apply_logging_config
from pymodbus.transaction import ModbusSocketFramer
from pymodbus.logging import Log
from pymodbus.transaction import ModbusSocketFramer
from typing_extensions import Annotated

from pymodbus_repl.lib.reactive import (
Expand Down

0 comments on commit d05af3a

Please sign in to comment.