Throw AttributeError for NIRNode constructor #122
Merged
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.
Fix for #120
NIRNodefrom abc. This might be too much, but given that the stated documentation forNIRNodeis that it is a "base superclass" and that "NIRNodes should never be instantiated", indicating this property through inheritance in a Pythonic way.AttributeErroron callNIRNode.__init__as a proposed fix for Issue 120.test_nodewhich checks if aNIRNodeclass can be constructed. All tests pass, it seems.Potential Downsides
abc.ABCmight have some unintended consequences in behavior that I am not familiar with, this change I think can be discarded if there are any unintended problems that arise.NIRNode, they will find that__init__is in fact defined. However, the exception raised here is one used to indicate that there is in fact no__init__method. One potential alternative is to raiseTypeError, which "may be raised by user code to indicate that an attempted operation on an object is not supported, and is not meant to be".P.S. This is my first attempted contribution to an open-source library ❤️