Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserWarning: Pydantic serializer warnings: Expected Union[bool, int, str, dict[str, str]] but got list - serialized value may not be as expected #117

Open
ptrba opened this issue Apr 17, 2024 · 0 comments

Comments

@ptrba
Copy link

ptrba commented Apr 17, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant