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
Add runtime generic alias support to datetime #161304
@srittau has merged a PR with a support of parametrising datetime type with a timezone information in the typeshed. Allowing datetime to be a generic would let use that feature without workarounds in Python.
The typeshed change could be a huge help to detect (sometimes rather subtle) bugs with naïve vs tz-aware datetimes.
Nevertheless, the change is new and hasn't made it into any type checkers yet (as far as I'm aware). It might turn out to be too controversial and might need backing out in typeshed (although I hope not). So I would wait maybe 1-2 months with this to make sure we keep the change in typeshed.
That said, if we keep it, this would be quite helpful and would be in line with similar changes we've made to CPython.
What about datetime.time? It also has tzinfo parameter in some places:
That seems ... weird. For consistency's sake, we should probably make it generic in typeshed and CPython, although I'm not sure what a time with a tzinfo parameter is even supposed to represent.
Activity
srittau commentedon Nov 4, 2026
A few comments:
sobolevn commentedon Nov 4, 2026
What about
datetime.time? It also hastzinfoparameter in some places:srittau commentedon Nov 4, 2026
That seems ... weird. For consistency's sake, we should probably make it generic in typeshed and CPython, although I'm not sure what a
timewith atzinfoparameter is even supposed to represent.