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

Use explicit ValueError when called with incorrect function code #2089

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

alexrudd2
Copy link
Collaborator

See #1599 for background.

The current code has a check if fc_as_hex in self._write_fc:. If this check fails, it means the function was called with a Modbus function code which isn't a write.

This will never happen normally. If there is bad calling code, a confusing NameError is thrown because self.result is undefined.

This PR makes the check explicit (and solves another mypy error). An alternative is to simply delete the check.

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

I like this one!

@janiversen janiversen merged commit 07c43b5 into dev Mar 7, 2024
1 check passed
@janiversen janiversen deleted the remote-datastore-fc branch March 7, 2024 07:25
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants