Skip to content

Commit c7c0802

Browse files
solve more mypy issues with datastore (#2010)
* solve more mypy issues with datastore * pylint make up your mind! --------- Co-authored-by: jan iversen <[email protected]>
1 parent 21cb2e6 commit c7c0802

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

pymodbus/datastore/simulator.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ class Cell:
3737
count_write: int = 0
3838

3939

40+
class TextCell: # pylint: disable=too-few-public-methods
41+
"""A textual representation of a single cell."""
42+
43+
type: str
44+
access: str
45+
value: str
46+
action: str
47+
action_kwargs: str
48+
count_read: str
49+
count_write: str
50+
51+
4052
@dataclasses.dataclass
4153
class Label: # pylint: disable=too-many-instance-attributes
4254
"""Defines all dict values.
@@ -94,7 +106,7 @@ class Setup:
94106
def __init__(self, runtime):
95107
"""Initialize."""
96108
self.runtime = runtime
97-
self.config = None
109+
self.config = {}
98110
self.config_types = {
99111
Label.type_bits: {
100112
Label.type: CellType.BITS,
@@ -454,10 +466,10 @@ class ModbusSimulatorContext:
454466
start_time = int(datetime.now().timestamp())
455467

456468
def __init__(
457-
self, config: dict[str, Any], custom_actions: dict[str, Callable]
469+
self, config: dict[str, Any], custom_actions: dict[str, Callable] | None
458470
) -> None:
459471
"""Initialize."""
460-
self.registers: list[int] = []
472+
self.registers: list[Cell] = []
461473
self.fc_offset: dict[int, int] = {}
462474
self.register_count = 0
463475
self.type_exception = False
@@ -474,7 +486,7 @@ def __init__(
474486
def get_text_register(self, register):
475487
"""Get raw register."""
476488
reg = self.registers[register]
477-
text_cell = Cell()
489+
text_cell = TextCell()
478490
text_cell.type = self.registerType_id_to_name[reg.type]
479491
text_cell.access = str(reg.access)
480492
text_cell.count_read = str(reg.count_read)

0 commit comments

Comments
 (0)