ListSelector doesn't check the type
There seems to be two issues with ListSelector.
It raises a TypeError when the type is wrong (e.g. p.ls = 1). Which doesn't sound so bad but param actually raises a ValueError in those cases, e.g. for a Number parameter: ValueError: Parameter 'n' only takes numeric values, not type <class 'str'>.. For consistency, should it also raise a ValueError?
ListSelector doesn't check that the type is a list which means that this snippet doesn't fail:
import param
class A(param.Parameterized):
ls = param.ListSelector('ab', ['a', 'b', 'c', 'd'])
a = A()
a.ls = 'cd'
Is this a bug?
It also doesn't set the default value as the first item of objects if default is not provided:
import param
class A(param.Parameterized):
ls = param.ListSelector(objects=['a', 'b', 'c', 'd'])
a = A()
a.ls is None # True
Yes, definite bug.
It also doesn't set the default value as the first item of objects if default is not provided:
It definitely shouldn't do that in any case, default=None is perfectly valid (and forces allow_None).
It definitely shouldn't do that in any case,
default=Noneis perfectly valid (and forcesallow_None).
Oh yes right I thought for some reason that it had the same behavior as Selector.