Make exceptions hashable (but not comparable) #502
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.
This PR addresses #477.
Currently,
ValidationError
andSchemaError
implement__eq__
, but don't implement__hash__
, which makes then unhashable. That prevents them from being used in certain scenarios, notably in a test suite that usespytest
[Edit: It fails under python 3.6, but not 3.7].The easiest way to make them hashable is to simply remove the
__eq__
implementation. I doubt many users ofjsonschema
rely on the fact that those errors are comparable.The only problem is jsonschema's own test suite, which does rely on
ValidationError.__eq__()
. But that's easy to change, as I've done in this PR. Thoughts?