Skip to content

Commit

Permalink
solve more mypy issues with datastore (#2010)
Browse files Browse the repository at this point in the history
* solve more mypy issues with datastore

* pylint make up your mind!

---------

Co-authored-by: jan iversen <[email protected]>
  • Loading branch information
alexrudd2 and janiversen authored Feb 13, 2024
1 parent 21cb2e6 commit c7c0802
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pymodbus/datastore/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ class Cell:
count_write: int = 0


class TextCell: # pylint: disable=too-few-public-methods
"""A textual representation of a single cell."""

type: str
access: str
value: str
action: str
action_kwargs: str
count_read: str
count_write: str


@dataclasses.dataclass
class Label: # pylint: disable=too-many-instance-attributes
"""Defines all dict values.
Expand Down Expand Up @@ -94,7 +106,7 @@ class Setup:
def __init__(self, runtime):
"""Initialize."""
self.runtime = runtime
self.config = None
self.config = {}
self.config_types = {
Label.type_bits: {
Label.type: CellType.BITS,
Expand Down Expand Up @@ -454,10 +466,10 @@ class ModbusSimulatorContext:
start_time = int(datetime.now().timestamp())

def __init__(
self, config: dict[str, Any], custom_actions: dict[str, Callable]
self, config: dict[str, Any], custom_actions: dict[str, Callable] | None
) -> None:
"""Initialize."""
self.registers: list[int] = []
self.registers: list[Cell] = []
self.fc_offset: dict[int, int] = {}
self.register_count = 0
self.type_exception = False
Expand All @@ -474,7 +486,7 @@ def __init__(
def get_text_register(self, register):
"""Get raw register."""
reg = self.registers[register]
text_cell = Cell()
text_cell = TextCell()
text_cell.type = self.registerType_id_to_name[reg.type]
text_cell.access = str(reg.access)
text_cell.count_read = str(reg.count_read)
Expand Down

0 comments on commit c7c0802

Please sign in to comment.