GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make datetime generic over tzinfo by srittau · Pull Request #11844 · python/typeshed

Make datetime generic over tzinfo #11844

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.

Sign up for GitHub

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

Merged
srittau merged 47 commits into python:main from srittau:datetime-tzinfo
Nov 3, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Make datetime generic over tzinfo #11844

Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4c32d0c
Make datetime generic over tzinfo
srittau Apr 29, 2024
e2a3800
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 29, 2024
814df90
Ignore stubtest error
srittau Apr 29, 2024
a5492ba
Overload operators
srittau Apr 29, 2024
d176a1d
Update some type ignores
srittau Apr 29, 2024
040dbcb
Ignore some mypy errors
srittau Apr 29, 2024
7ce96ea
Make pyright a bit happier
srittau Apr 29, 2024
ce3ee77
Add another type ignore
srittau Apr 29, 2024
c59db10
Make pyright mostly happy
srittau Apr 29, 2024
c0d5cc1
Set default to `Any`
srittau Apr 29, 2024
eb4f7d8
Make both, pyright and mypy happy
srittau Apr 29, 2024
14aa5d2
Annotate datetime.today()
srittau Apr 29, 2024
d8d9d41
Use explicit datetime annotation in test
srittau Apr 29, 2024
f656dbb
Revert bound, use covariance
srittau Apr 29, 2024
25a3e48
Annotate datetime.strptime()
srittau Apr 29, 2024
ce3c470
Reshuffle annotations; use Any as default again
srittau Apr 29, 2024
b148970
Add some type ignores
srittau Apr 29, 2024
f9d5875
Merge branch 'main' into datetime-tzinfo
srittau Nov 10, 2025
605f598
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 10, 2025
510c87f
Revert unittest tests
srittau Nov 10, 2025
2b2c314
Fix a test
srittau Nov 10, 2025
cbf66a8
Add another type ignore
srittau Nov 10, 2025
4974026
Restore changes to check_unittest
srittau Nov 10, 2025
d7b69b1
Fix grouping
srittau Nov 10, 2025
9b8d191
Merge branch 'main' into datetime-tzinfo
srittau Dec 20, 2025
a903506
Merge branch 'main' into datetime-tzinfo
srittau Jan 23, 2026
c57ace3
Merge branch 'main' into datetime-tzinfo
srittau Oct 28, 2026
94cd215
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2026
ae727f4
Fix merge problems
srittau Oct 28, 2026
99c7433
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2026
2683f1b
Change `_TzInfoT` default to `tzinfo | None`
srittau Oct 28, 2026
86b5ced
Use `datetime[None]` for `datetime.{min,max}`
srittau Oct 28, 2026
73d99dc
Remove datetime.fromisoformat() override
srittau Oct 28, 2026
147cfa8
Return `datetime[_TzInfo]` from `astimezone()`
srittau Oct 28, 2026
2df8134
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2026
e2efb0e
Revert `Final` change
srittau Oct 28, 2026
79e966e
Use `datetime[_TzInfo] | datetime[None]` as strptime() return type
srittau Oct 28, 2026
9d1f57a
Use `Any` default for `_TzInfoT`
srittau Oct 28, 2026
15cd3aa
Return `datetime` from `fromisoformat`
srittau Oct 28, 2026
45db0fb
Split fromisoformat datetime union
srittau Oct 29, 2026
d95f348
Update a test
srittau Oct 29, 2026
0e3099c
Remove special casing of datetime.strptime()
srittau Oct 29, 2026
ebf7984
Restore explicit datetime.strptime with changed return type
srittau Oct 29, 2026
d515efb
Fix missing import
srittau Oct 29, 2026
8b0f3a4
Add an extra overload to datetime.fromtimestamp
srittau Oct 29, 2026
637848c
Fix date.fromisoformat
srittau Nov 1, 2026
8656ee9
Remove obsolete comment
srittau Nov 1, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
Fix date.fromisoformat
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@srittau
srittau authored Nov 1, 2026
commit 637848c7c728124a9c55f99cec92b66b4e50b50a

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

12 changes: 10 additions & 2 deletions 12 stdlib/datetime.pyi
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class date:
# fromisoformat returns Self, but we can't specialize "Self"
if sys.version_info >= (3, 15):
@classmethod
def fromisoformat(cls, string: str, /) -> datetime[_TzInfo] | datetime[None]: ...
def fromisoformat(cls, string: str, /) -> Self: ...
else:
@classmethod
def fromisoformat(cls, date_string: str, /) -> datetime[_TzInfo] | datetime[None]: ...
def fromisoformat(cls, date_string: str, /) -> Self: ...

@classmethod
def fromisocalendar(cls, year: int, week: int, day: int) -> Self: ...
Expand Down Expand Up @@ -353,6 +353,14 @@ class datetime(date, Generic[_TzInfoT]):
@classmethod
def fromtimestamp(cls, timestamp: float, /, tz: _TzInfo | None) -> datetime[_TzInfo] | datetime[None]: ...

# fromisoformat returns Self, but we can't specialize "Self"
if sys.version_info >= (3, 15):
@classmethod
def fromisoformat(cls, string: str, /) -> datetime[_TzInfo] | datetime[None]: ... # type: ignore[override]
else:
@classmethod
def fromisoformat(cls, date_string: str, /) -> datetime[_TzInfo] | datetime[None]: ... # type: ignore[override]

@classmethod
@deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.UTC)")
def utcfromtimestamp(cls, t: float, /) -> datetime[None]: ...
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.