Use of WidgetBase raises ParamFutureWarning
- Dominant language
- Python
- Stars
- 521
- Forks
- 86
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 35
Description
I'm on panel==1.5.0rc2 and param==2.1.1.
I have a custom `CompositeWidget` that I noticed started raising a `ParamFutureWarning`. After some inspection I can see the problem is is caused by the fact that the `WidgetBase.value` is a `Parameter` while my `CustomWidget.value` is a `String`.
I think this will be cause general problems as `WidgetBase` is now intended to be mixed into all kinds of custom widgets.
## Reproduce
```python
import panel as pn
from panel.widgets.base import WidgetBase
import param
class CustomWidget(pn.viewable.Viewer, WidgetBase):
value = param.String()
def __panel__(self):
return self.param.value
CustomWidget(value="Hello World").servable()
```
```bash
/home/jovyan/repos/mt-pm-reporting/script.py:5: ParamFutureWarning: String parameter 'CustomWidget.value' failed to validate its default value on class creation, this is going to raise an error in the future. The Parameter type changed between class 'CustomWidget' and one of its parent classes (Viewer, WidgetBase) which made it invalid. Please fix the Parameter type.
Validation failed with:
String parameter 'CustomWidget.value' only takes a string value, not value of .
value = param.String()
```
## Workaround
Change `param.String()` to `param.String("")`. Then the `ParamFutureWarning` will not be raised.
Contributor guide
Assessment
This issue has not been assessed yet.