Report offending input in parametrized module error messages - #1103
Open
jaewonyun1234 wants to merge 1 commit into
Open
jaewonyun1234 wants to merge 1 commit into
jaewonyun1234 wants to merge 1 commit into
Conversation
Error messages that only stated a rule now also report the value that broke it. Covers 5 messages: 3 in variable.py, where three of the four checks in Variable.__post_init__ did not say what was given, and 2 in paramobj.py, which now name the method that could not be serialized. The two errors raised for calls to parametrized objects are left unchanged: ParamObj.__call__ already warns at the call site and the warning carries the same object, so repeating it adds nothing. Existing assertions that stopped before the reported value are extended to the end of the message.
a-corni
reviewed
Sep 9, 2026
Comment on lines
+49
to
+50
| "Variable's 'name' has to be of type 'str', not " | ||
| f"{type(self.name)}." |
Member
There was a problem hiding this comment.
Maybe is it worth returning the input that failed ?
Suggested change
| "Variable's 'name' has to be of type 'str', not " | |
| f"{type(self.name)}." | |
| "Variable's 'name' has to be of type 'str', not " | |
| f"{type(self.name)} (got {self.name!r})." |
Comment on lines
+56
to
+57
| "Variable's 'size' has to be of type 'int', not " | ||
| f"{type(self.size)}." |
Member
There was a problem hiding this comment.
Here as well
Suggested change
| "Variable's 'size' has to be of type 'int', not " | |
| f"{type(self.size)}." | |
| "Variable's 'size' has to be of type 'int', not " | |
| f"{type(self.size)} (got {self.size!r})." |
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.
Hi @a-corni, @HGSilveri,
Following on from #1095, #1097, #1098 and #1102, this covers the parametrized module: 5 messages, 3 in
variable.pyand 2 inparamobj.py.The two in
paramobj.pyare the same message raised from_to_dictand_to_abstract_repr. Both now name the method that couldn't be serialized, e.g.got 'Register.rotated'.I left the
Serialization of calls to parametrized objects is not supportedpair unchanged. Calling a parametrized object already warns at that line, and the warning includes the same object, so repeating it in the error adds nothing.Partially addresses #1057.