Skip to content

[python-dateutil] tzoffset.tzname and tzfile.tzname can return None - #16818

Merged
srittau merged 1 commit into
python:mainfrom
hemtilva:dateutil-tzname-optional
Nov 16, 2026
Merged

srittau merged 1 commit into
python:mainfrom
hemtilva:dateutil-tzname-optional

Conversation

@hemtilva

Copy link
Copy Markdown
Contributor

Fixes #16817

tzoffset.tzname returns the name the offset was created with, which is None for unnamed offsets. That includes the ones dateutil.parser builds, so parse("2020-01-01T00:00+01:00").tzname() is None. tzfile.tzname returns None when dt is None. Both were annotated -> str; this changes them to -> str | None, matching datetime.tzinfo.tzname.

Checked with mypy on stubs/python-dateutil and stubtest locally. stubtest on Windows only complains about dateutil.tz.tzwinbase, which is unrelated.

I used Claude to help find this and write the change.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 05:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau
srittau merged commit 8e21ebd into python:main Nov 16, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[python-dateutil] tzoffset.tzname and tzfile.tzname can return None

3 participants