Skip to content

Fix signed and sub-millisecond duration read round trips - #219

Open
Mirochill wants to merge 1 commit into
opendecree:mainfrom
Mirochill:fix-duration-roundtrip
Open

Mirochill wants to merge 1 commit into
opendecree:mainfrom
Mirochill:fix-duration-roundtrip

Conversation

@Mirochill

Copy link
Copy Markdown

Summary

Reading a typed duration of one microsecond produces 1e-06s, which the Go-style duration parser rejects. Negative durations fail too, including values written through timedelta. Format fractional seconds with integer arithmetic in decimal notation and accept one optional leading sign for the whole duration. Add signed/compound/invalid-sign cases and protobuf duration round trips, retaining Python's microsecond precision.

Test plan

  • Eleven new regression cases fail against upstream; the other five new controls pass.
  • cd sdk && ../.venv-ci/bin/python -m pytest --cov --cov-report=term-missing: 327 passed, 13 live-server tests skipped, 100% coverage (upstream baseline: 311 passed, 13 skipped, 100%).
  • .venv-ci/bin/ruff check sdk/src/ sdk/tests/ and .venv-ci/bin/ruff format --check sdk/src/ sdk/tests/: pass.
  • cd sdk && ../.venv-ci/bin/mypy src/: pass on all 29 source files.
  • .venv-ci/bin/python -m build sdk/ --wheel --outdir ../validation/decree-wheel: pass; py.typed and .pyi contents verified.
  • Example syntax compilation and git diff --check: pass.

Validation used Python 3.12.14 and the SDK's dev dependencies. Live-server integration and Docker example execution were not run; the existing AsyncMock warning remains. No protobuf schemas or generated stubs changed.

Assisted-by: OpenAI Codex

@github-actions

Copy link
Copy Markdown

Thanks for your first pull request! We appreciate the contribution.

Before review, please make sure tests pass: cd sdk && pytest

This branch has not been deployed

No deployments
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