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
Recommend DateType in the datetime documentation #105563
At the PyCon US 2023 sprints, I spent some time with @glyph, @hauntsaninja, @AlexWaygood and others trying to put together a plan to make the type stubs for datetime distinguish between naïve and aware datetimes (even if the runtime types don't reflect this). Unfortunately, we came to the conclusion that there's no way to do it in a backwards-compatible way that accounts for subclasses without the use of higher-kinded types (this is not the first time we came to that conclusion, and unfortunately in neither case did we write down the exact reason this is a problem as far as I know, so, uh... let's remember to do that next time we tilt at this particular windmill).
Some time ago, however, @glyph did come up with a set of Protocol classes that basically solves the problem for anyone who is willing to opt in to it, since that frees him from certain backwards compatibility concerns. The upshot of the conversation was that the best we can do from the CPython side is probably to add a link to DateType into the datetime documentation, presumably in the "See also" infobox, along with a recommendation that it can be used to improve type checking of naïve vs. aware datetimes.
I realized that we didn't get around to this in the sprints and we never made an issue to track the progress, so when this recently came up in this issue, it reminded me to open this issue.
Hi @rakesh9541! Unfortunately there is already an open PR to address this issue: #105946. I would be better to wait until that has been reviewed before opening another one :)
Activity
rakesh9541 commentedon Jul 6, 2023
can you assign me this??
AlexWaygood commentedon Jul 6, 2023
Hi @rakesh9541! Unfortunately there is already an open PR to address this issue: #105946. I would be better to wait until that has been reviewed before opening another one :)
gh-105563: reference DateType in datetime's documentation (#105946)
pythongh-105563: reference DateType in datetime's documentation (pyth…
pythongh-105563: reference DateType in datetime's documentation (pyth…
[3.11] gh-105563: reference DateType in datetime's documentation (GH-…
[3.12] gh-105563: reference DateType in datetime's documentation (GH-…
tigercosmos commentedon Oct 29, 2023
this one should be closed?
glyph commentedon Oct 29, 2023
yep, the recommendation is definitely there in the docs now