django-bootstrap-datepicker-plus
django-bootstrap-datepicker-plus copied to clipboard
UserWarning: Pydantic serializer warnings: Expected `Union[bool, int, str, dict[str, str]]` but got `list` - serialized value may not be as expected
To Reproduce Using options https://getdatepicker.com/4/Options/#daysofweekdisabled for example:
picker = DatePickerInput(options={'daysOfWeekDisabled': [0,6]})
picker.config.to_attr_value()
will show:
UserWarning: Pydantic serializer warnings:
Expected `Union[bool, int, str, dict[str, str]]` but got `list` - serialized value may not be as expected
This warning does not have any consequences. The picker is rendered correctly.
As far as I can judge, this is due to schemas.py:9
WidgetOptions: TypeAlias = Dict[str, Union[bool, int, str, Dict[str, str]]]
where Union
does not include list. Thus a fix:
WidgetOptions: TypeAlias = Dict[str, Union[bool, int, str, Dict[str, str],list[int]]]
should do the job. I did not go through all options of https://getdatepicker.com/4/Options/. There might be more of these typing issues. A less restrictive schema might be more appropriate here:
WidgetOptions: TypeAlias = Dict[str, typing.Any]
Expected behavior
There should be no warning.
Setup Information (please complete the following information):
- django-bootstrap-datepicker-plus==5.0.5