Skip to content

Reject duration components without a unit designator - #31

Open
rupayon123 wants to merge 1 commit into
bolsote:masterfrom
rupayon123:contribution/reject-unitless-components-20260922
Open

rupayon123 wants to merge 1 commit into
bolsote:masterfrom
rupayon123:contribution/reject-unitless-components-20260922

Conversation

@rupayon123

Copy link
Copy Markdown

Fixes #25 and the ignored trailing-component cases in #21. Numeric date/time values without a following designator currently disappear: P1 becomes zero, P1MT1 loses its time value, and P1Y2T3H loses the 2. Reject pending numeric values at the date/time boundary and at end of input with UnparseableValue. Existing full alternate date-time parsing stays on its current path.

Eleven new missing-unit cases fail before the change. The old PT000022.22 test expected silent conversion to zero; it is moved into the invalid-input cases, while valid zero durations and complete signed/fractional components remain covered. An initial control incorrectly expected PT0S formatting to remain PT0S; corrected it to the existing canonical P0D output, without changing formatting.

Afterward: all 391 tests pass, 100% reported source/branch coverage, scoped Black/Flake8, strict source mypy and git diff --check pass on Python 3.12.13. Tests explicitly use this checkout's src to keep this branch independent of the operator-fallback PR.

Prepared with AI assistance; parser boundaries, compatibility fixtures and validation results were reviewed.

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.

Durations without units aren't valid durations

1 participant