Make sure any BaseNode always has a valid Node ID#657
Open
acolomb wants to merge 1 commit intocanopen-python:masterfrom
Open
Make sure any BaseNode always has a valid Node ID#657acolomb wants to merge 1 commit intocanopen-python:masterfrom
acolomb wants to merge 1 commit intocanopen-python:masterfrom
Conversation
The BaseNode.id attribute can be initialized either from the given node_id parameter, or from the Object Dictionary if zero was passed. The None value as mentioned in the docstring actually violates the type hint, so drop that suggestion. Make sure the inferred type of the self.id attribute does not allow None, but is always an integer. Furthermore, check the resulting Node ID against the allowed value range and raise a ValueError instead of constructing a node object with an invalid Node ID, which will cause problems down the road. This is technically an API change, but it just causes things to fail early on instead of raising exceptions later on. Copy the docstring for LocalNode as well, to document the expected node_id "invalid" value. And because there was none at all before, include a bit of functional description to set the expectations straight.
Member
Author
|
Replaces #650, as far as Node ID assumptions are concerned. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The BaseNode.id attribute can be initialized either from the given node_id parameter, or from the Object Dictionary if zero was passed. The None value as mentioned in the docstring actually violates the type hint, so drop that suggestion. Make sure the inferred type of the self.id attribute does not allow None, but is always an integer.
Furthermore, check the resulting Node ID against the allowed value range and raise a ValueError instead of constructing a node object with an invalid Node ID, which will cause problems down the road. This is technically an API change, but it just causes things to fail early on instead of raising exceptions later on.
Copy the docstring for LocalNode as well, to document the expected node_id "invalid" value. And because there was none at all before, include a bit of functional description to set the expectations straight.