Closed maximlt closed 1 year ago
@philippjfr this is ready.
Thanks. Now seems like a good chance to make the error message a bit cleaner. Instead of ", not type <class 'str'>", can it be either ", not <class 'str'>", or ", not type 'str'", (my preference, I think)? I'm a bit confused why it comes out that way right now, as if I do "type('st')" I get "str", not the confusing version.
Yes that'd be a good idea! I won't have time to take care of that now though.
Ah, apparently Python only shows the __name__
of the type when used interactively, so it would be f", not '{type(obj).__name__}'"
(yielding , not 'str'
).
Personally I find , not 'str'
a little weird, the single quotes throw me off.
The error messages raised by Parameters are pretty inconsistent and often lack context.
For now with this PR I'm just seeking feedback on a utility I've added that builds a message supposed to prefix most of (if not all) the errors raised by Parameters. I've just adapted the type validation performed by
Number
to show the error messages emitted in various situations:(I'd hope to get this into the 2.0 release.)