Skip to content

Reject datetime strings in the date factory - #673

Open
jadenfix wants to merge 1 commit into
python-poetry:masterfrom
jadenfix:reject-datetime-in-date-factory
Open

jadenfix wants to merge 1 commit into
python-poetry:masterfrom
jadenfix:reject-datetime-in-date-factory

Conversation

@jadenfix

@jadenfix jadenfix commented Oct 18, 2026 •

Copy link
Copy Markdown

Summary

tomlkit.date() currently accepts a local or offset timestamp and returns a DateTime, because Python's datetime subclasses date. Reject datetime values with the existing date-only ValueError, preserving valid dates and the separate datetime() factory.

Adds regressions for local, UTC, and non-UTC offset timestamps. All three fail before the fix. The complete suite passes: 1,206 tests on Python 3.12.13, including the pinned toml-test submodule. All repository pre-commit hooks pass; the local pre-commit runner was upgraded because the declared 2.20 version cannot parse the current hook manifest's stage names. An installed-wheel consumer round-trips a real date/datetime TOML document through stdlib tomllib and checks timestamp rejection. Other interpreter versions and upstream CI are not yet verified.

The earlier #645 addressing this behavior was self-closed unmerged; this change was developed from the current factory and its date-only contract.

Agent Drafting Metadata

  • Agent: OpenAI Codex
  • Model: GPT-6-based Codex; the exact deployment model identifier is not exposed in this session
  • Notes: Codex prepared the implementation, regression tests, and this description. A separate Codex agent independently reviewed exact commit 5ef0158 and ran the seven date-related API tests, with no unresolved findings. This is automated review, not human maintainer review.

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.

1 participant