refactor: centralize nanoseconds constant - #77
Conversation
The shared NANOSECONDS_PER_SECOND landed between the grid-resampling policy comment and the RESAMPLE_POLICY_VERSION it documents. Move it above that block with its own note. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
kstonekuan
left a comment
There was a problem hiding this comment.
Thank you @nightcityblade, and welcome! Exactly the change the issue asked for, with the verification command in the description so the result is easy to confirm.
What I validated locally:
- Full quality gate is clean (
ruff check,ruff format --check,ty check) and all 307 tests pass. - Confirmed
rg -n "NANOSECONDS_PER_SECOND = " src/hflow/now reports exactly one definition. - Checked that importing
hflow.formatfromresample.pyintroduces no import cycle.format.pyis leaf-level by design, which is what makes it the right home.
One fixup pushed to your branch (f0521b1): the constant landed between the grid-resampling policy comment and the RESAMPLE_POLICY_VERSION that comment documents ("bump this when the grid or selection semantics change"), so I moved it above that block with its own note. That placement was my issue text's fault for saying "near RESAMPLE_POLICY_VERSION, which already describes the grid semantics"; your reading of it was reasonable.
Merging now. If you want another, the open good first issues have plenty left, and #62 is the close cousin of this one (same shape, different constants). Issues with an assignee are taken; everything else is fair game. We also hang out on Discord.
Summary
Define
NANOSECONDS_PER_SECONDonce inhflow.formatand import it fromresampleandtesting.Closes #63.
Why
The identical time-unit constant was maintained in two modules. Moving it to the established shared format-constants module removes that duplication without changing behavior.
Validation
uv sync --locked --all-extras— passed.uv run ruff check --fix— passed.uv run ruff format— 88 files left unchanged.uv run ty check— passed.uv run pytest -qin Debian with Python 3.11 and FFmpeg — 307 passed, 3 skipped.rg -n "NANOSECONDS_PER_SECOND = " src/hflow/— exactly one definition.Checklist
uv run ruff check --fix,uv run ruff format, anduv run ty check.