Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pymodbus/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ class ModbusControlBlock:

__mode = "ASCII"
__diagnostic = [False] * 16
__instance = None
__listen_only = False
__delimiter = "\r"
__counters = ModbusCountersHandler()
Expand Down
7 changes: 4 additions & 3 deletions pymodbus/repl/client/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# pylint: disable=missing-type-doc
import json
from collections import OrderedDict
from typing import Any, Dict, List, Union

import pygments
from prompt_toolkit import print_formatted_text
Expand Down Expand Up @@ -58,7 +59,7 @@
"set_timeout",
"get_serial_settings",
]
CLIENT_ATTRIBUTES = []
CLIENT_ATTRIBUTES: List[str] = []


class Command:
Expand Down Expand Up @@ -230,8 +231,8 @@ def get_commands(client):
class Result:
"""Represent result command."""

function_code = None
data = None
function_code: int = None
data: Union[Dict[int, Any], Any] = None

def __init__(self, result):
"""Initialize.
Expand Down
7 changes: 5 additions & 2 deletions pymodbus/server/async_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ssl
import time
import traceback
from typing import Union

from pymodbus.client.serial_asyncio import create_serial_connection
from pymodbus.constants import Defaults
Expand Down Expand Up @@ -873,7 +874,7 @@ class ModbusSerialServer: # pylint: disable=too-many-instance-attributes
server context instance.
"""

handler = None
handler: ModbusSingleRequestHandler = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handler can be all 3 handlers, but I am ok with only typing one of them.


def __init__(
self, context, framer=ModbusRtuFramer, identity=None, **kwargs
Expand Down Expand Up @@ -1052,7 +1053,9 @@ class _serverList:
:meta private:
"""

active_server = None
active_server: Union[
ModbusUnixServer, ModbusTcpServer, ModbusUdpServer, ModbusSerialServer
] = None

def __init__(self, server):
"""Register new server."""
Expand Down
3 changes: 2 additions & 1 deletion pymodbus/server/reactive/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import threading
import time
from enum import Enum
from typing import Union


try:
Expand Down Expand Up @@ -396,7 +397,7 @@ def create_identity(
def create_context(
cls,
data_block_settings: dict = {},
unit: list[int] = [1],
unit: Union[list[int]] | int = [1],
single: bool = False,
randomize: int = 0,
change_rate: int = 0,
Expand Down
24 changes: 23 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,29 @@ noqa-require-code = True

[mypy]
strict_optional = False
exclude = pymodbus/client/base.py
exclude = pymodbus/client/base.py

# below are those used in HomeAssistant
show_error_codes = true
# follow_imports = silent
# ignore_missing_imports = true
local_partial_types = true
strict_equality = true
warn_incomplete_stub = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true
enable_error_code = ignore-without-code, redundant-self, truthy-iterable
disable_error_code = annotation-unchecked
strict_concatenate = false
# check_untyped_defs = true
# disallow_incomplete_defs = true
disallow_subclassing_any = true
# disallow_untyped_calls = true
disallow_untyped_decorators = true
# disallow_untyped_defs = true
# warn_return_any = true
warn_unreachable = true


[egg_info]
Expand Down