Open
Labels
stdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-featureA feature request or enhancement
Description
Feature or enhancement
@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.
from datetime import datetime, UTC
global_now: datetime[UTC] = datetime.now(UTC)
local_now: datetime[None] = datetime.now()Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
Linked PRs
Reacted by Sebastian Rittau
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-featureA feature request or enhancement
Projects
- StatusShow more project fieldsNo status
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.