You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
component typing id as dict and datetime for Date pickers in Dash 3.0rc1 #3141
Hi, I tried to update to dash 3.0rc1, and what I noticed is that some typehints are too strict. What I found:
ids are typed as typing.Optional[str], omitting dict ids
dates in datepickers are typed as typing.Optional[str], but we use datetime.dates without problem, not sure if dates working is intended or just a coincidence though
There are possibly others, this is what I found in our codebase.
changed the title [-][BUG] Dash 3.0rc1 too strict typehints[/-][+][BUG] Dash 3.0rc1, component typing id as dict and datetime for Date pickers[/+]on Feb 6, 2025
changed the title [-][BUG] Dash 3.0rc1, component typing id as dict and datetime for Date pickers[/-][+]component typing id as dict and datetime for Date pickers in Dash 3.0rc1[/+]on Feb 13, 2025
I think it would be better to allow datetime.date only. Otherwise it is possible to init the datepicker with something that has time different from midnight (this still correctly sets the date in ui), and if the user does not change the date, then the time is read back into callbacks, which can be surprising in my opinion. In the attached example, 2025-03-18T14:17:32.244956 is shown, instead of just the date.
Oh, of course. Then both date and datetime is fine. It could maybe be nice to throw away the time part in the component if present, but that is out of the scope of this issue.
Activity
[-][BUG] Dash 3.0rc1 too strict typehints[/-][+][BUG] Dash 3.0rc1, component typing id as dict and datetime for Date pickers[/+][-][BUG] Dash 3.0rc1, component typing id as dict and datetime for Date pickers[/-][+]component typing id as dict and datetime for Date pickers in Dash 3.0rc1[/+]tlauli commentedon Mar 18, 2025
@T4rk1n Hi, I see the the types were expanded to allow
datetime.datetimefor dates in datepicker, but it should bedatetime.date.T4rk1n commentedon Mar 18, 2025
My bad, I tested with
datetime.datetime.now()and assumed it was the same, it should be union of both.tlauli commentedon Mar 18, 2025
I think it would be better to allow
datetime.dateonly. Otherwise it is possible to init the datepicker with something that has time different from midnight (this still correctly sets the date in ui), and if the user does not change the date, then the time is read back into callbacks, which can be surprising in my opinion. In the attached example,2025-03-18T14:17:32.244956is shown, instead of just the date.T4rk1n commentedon Mar 18, 2025
The base class is
datetime.date, it handle both.tlauli commentedon Mar 18, 2025
Oh, of course. Then both
dateanddatetimeis fine. It could maybe be nice to throw away the time part in the component if present, but that is out of the scope of this issue.