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
Make argument type error messages use __str__
method of Predicate
s
#317
Conversation
Would you mind changing this to use |
plumbum/cli/application.py
Outdated
@@ -350,7 +350,7 @@ def _handle_argument(val, argtype, name): | |||
except (TypeError, ValueError): | |||
ex = sys.exc_info()[1] # compat | |||
raise WrongArgumentType("Argument of %s expected to be %r, not %r:\n %r" % ( | |||
name, argtype, val, ex)) | |||
name, str(argtype), val, ex)) |
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.
Something like:
raise WrongArgumentType("Argument of {name} expected to be {argtype}, not {val!r}:\n {ex!r}".format(
name=name, argtype=argtype, val=val, ex=ex))
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.
That works
As soon as Travis finishes, I'll accept. |
We've been using a ton of plumbum at bodylabs. It is replacing both our usages of argparse and of Bash, no less. Thank you for creating it. |
Previous behavior looks like this
now looks like this
when checking a
Predicate
.