Return an informative error message when spec should be a list #62
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.
glom
is great, thanks for making it!This PR makes the error message more informative when your target is a list and your spec is not.
Currently when target is a list but spec is not you get
ValueError: invalid literal for int() with base 10:
which doesn't immediately suggest that you forgot to make your spec a list. I've run into this a couple times now, and each time I forgot about last time and ended up having to check the source code to figure out what was going on. Next time I might finally remember, but for other people hitting this a different error message might help. With this change, the error message is
ValueError: Error indexing the target. This can happen when your target is a list and your spec is not. Did you forget to put brackets around your spec?
Please let me know if this check makes more sense somewhere else, I just put it right where the error first gets raised.
Thanks!
MWE: