Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve more mypy issues with datastore #2010

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Changes from 2 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
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:
"""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() # pylint: disable=no-value-for-parameter
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