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

Improve simulator type hints #2084

Merged
merged 3 commits into from
Mar 5, 2024
Merged
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
5 changes: 3 additions & 2 deletions pymodbus/datastore/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(self, runtime):
"""Initialize."""
self.runtime = runtime
self.config = {}
self.config_types = {
self.config_types: dict[str, dict[str, Any]] = {
Label.type_bits: {
Label.type: CellType.BITS,
Label.next: None,
Expand Down Expand Up @@ -748,11 +748,12 @@ def action_uptime(cls, registers, inx, cell, **_kwargs):
# Internal helper methods
# --------------------------------------------

def validate_type(self, func_code, real_address, count):
def validate_type(self, func_code, real_address, count) -> bool:
"""Check if request is done against correct type.

:meta private:
"""
check: tuple
Copy link
Collaborator

Choose a reason for hiding this comment

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

That is surely good news, that did not work 1-2 years ago.

Thanks.

if func_code in self._bits_func_code:
# Bit access
check = (CellType.BITS, -1)
Expand Down