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

Restrict write_registers etc to list[int]. #2469

Merged
merged 1 commit into from
Nov 24, 2024
Merged

Restrict write_registers etc to list[int]. #2469

merged 1 commit into from
Nov 24, 2024

Conversation

janiversen
Copy link
Collaborator

@janiversen janiversen commented Nov 24, 2024

Typing in python is really BAD !!

every developer would read this:

   values: list[int] | list[bytes]

as values can be either list[int] OR list[bytes], but mypy is stupid and requires values to be "list[int] | list[bytes]"

Using:

   values: Sequence[int | bytes]

solves this problem, but do NOT allow the array to be changed.

As a consequence of this, the API from now on only accept list[int], which are NOT modified !!

If an app wants to use bytes, it must be converted to int before calling. The API contains different from/to register conversions that can help if needed.

@janiversen janiversen merged commit 651bd61 into dev Nov 24, 2024
19 checks passed
@janiversen janiversen deleted the list branch November 24, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant