Skip to content

[stdlib] Restrict timespec parameter in datetime.{date,}time.isoformat - #16832

Merged
srittau merged 1 commit into
python:mainfrom
viccie30:datetime-timespec
Nov 16, 2026
Merged

srittau merged 1 commit into
python:mainfrom
viccie30:datetime-timespec

Conversation

@viccie30

Copy link
Copy Markdown
Contributor

Support for this parameter was added in #1349 and #3432, but it was typed as str. According to the documentation for datetime.isoformat and time.isoformat only certain values are allowed.

@github-actions

This comment has been minimized.

@viccie30 viccie30 changed the title Restrict timespec parameter in datetime.{date,}time.isoformat [stdlib] Restrict timespec parameter in datetime.{date,}time.isoformat Nov 16, 2026
Only certain values are allowed according to the documentation.
@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/_libs/tslibs/timestamps.pyi:220: error: Unused "type: ignore" comment  [unused-ignore]

@srittau
srittau merged commit b874edb into python:main Nov 16, 2026
88 checks passed
@viccie30
viccie30 deleted the datetime-timespec branch November 16, 2026 11:58
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.

2 participants