`allow_None` not enforced when set to `False` and the default value is `None`
maximlt opened this issue · 1 comments
Setting allow_None
to False
when the default
Parameter value is None
automatically sets it to True
. I believe Param shouldn't be doing that, when allow_None
is explicitly set to False
this value should be enforced. The annoying bit being that for Parameters whose default default
value is None
(like Callable
below) you'd have to provide a value that is not None
. Unless this applies only after the Parameter has been instantiated, to allow it to be instantiated with None
as the value for default
with allow_None=False
, but preventing it to be set to None
afterwards, which I believe is what you can do now with ObjectSelector
.
import param
class A(param.Parameterized):
c = param.Callable(allow_None=False)
print(A.param.c.allow_None)
# True!
Just got hit by this too. Would expect the below to raise an exception when trying to instantiate the Viewer
. Not before.
import param
class Viewer(param.Parameterized):
data = param.DataFrame(allow_None=False)
viewer = Viewer()
As an alternative we need a required
argument that makes it mandatory to specify the value on instantiation.