-
Notifications
You must be signed in to change notification settings - Fork 144
Bump typeguard from 2.13.3 to 4.0.0 #655
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from unittest import TestCase | ||
|
||
import pytest | ||
|
||
from spdx_tools.spdx.parser.error import SPDXParsingError | ||
from spdx_tools.spdx.parser.jsonlikedict.package_parser import PackageParser | ||
|
||
|
||
# To avoid duplication we use this invalid package as a proxy for the exact comparison of the generated error message. | ||
# For all other classes we only check that a TypeError is raised if an incorrect type is specified. | ||
def test_error_message(): | ||
package_parser = PackageParser() | ||
package = { | ||
"SPDXID": "SPDXRef-Package", | ||
"downloadLocation": 5, | ||
"attributionTexts": ["text", 5, {"test": "data"}], | ||
"packageFileName": 10, | ||
} | ||
|
||
with pytest.raises(SPDXParsingError) as err: | ||
package_parser.parse_package(package) | ||
|
||
TestCase().assertCountEqual( | ||
err.value.get_messages(), | ||
[ | ||
'Error while constructing Package: [\'SetterError Package: argument "name" ' | ||
"(None) is not an instance of str: None', 'SetterError Package: argument " | ||
'"download_location" (int) did not match any element in the union: ' | ||
"[str, spdx_tools.spdx.model.spdx_no_assertion.SpdxNoAssertion, " | ||
"spdx_tools.spdx.model.spdx_none.SpdxNone]: 5', 'SetterError Package: " | ||
'argument "file_name" (int) did not match any element in the union: ' | ||
"[str, NoneType]: 10', 'SetterError Package: item 1 of argument " | ||
"\"attribution_texts\" (list) is not an instance of str: [\\'text\\', 5, " | ||
"{\\'test\\': \\'data\\'}]']" | ||
], | ||
) |
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason why we don't print out the actual value anymore? I think this is quite useful to quickly pinpoint the source of the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two main reasons for this change, but they might be a matter of taste:
vs
Union
the error message is quite long and appending the real value doesn't really improve readability in my opinion,e.g.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, your first point is only valid for
None
, isn't it? I'm thinking more of cases with actual values, likeRegarding your second point, I now believe that the Union error message might not be very good after all, as it is much too verbose for what it actually says and might now even lead us to drop much more interesting information.
With some fancy string manipulation we should be able to reduce the size for Union-like type checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it is "valid" in every case, so at least in my opinion also the example you provided feels like a duplication but might help the user in such a way that he or she can search for the actual value...
Alright let's do "fancy string manipulation"..Will then need to be adapted once the error messages are changed again but as this only affects one place in the code I think this is reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented the string manipulation and added the value back in again.