param icon indicating copy to clipboard operation
param copied to clipboard

Validation error message confusing for unbound Parameters

Open maximlt opened this issue 3 years ago • 0 comments

When the validation of a Parameter fails before it's bound to its Parameterized class the error message doesn't report the class name and instead reports None. Running the example below emits ValueError: String parameter None only takes a string value, not value of type <class 'bool'>.

import param

class P(param.Parameterized):
    s = param.String(default=False)

There's a chance that there is some esoteric way to actually get the class name using the inspect module. If not, a better error message would already be an improvement.

In the example above the Parameter is in a transient state, it's meant to be bound to P. The same error message is raised when the Parameter is a pure unbound parameter, in which case the error message should probably include "Unbound".

import param

param.String(default=False)

maximlt avatar Mar 07 '23 10:03 maximlt