Move towards a dedicated Duration class (#19223)

We have various constants to try and avoid mistyping of durations, e.g.
`ONE_HOUR_SECONDS * MILLISECONDS_PER_SECOND`, however this can get a
little verbose and doesn't help with typing.

Instead, let's move towards a dedicated `Duration` class (basically a
[`timedelta`](https://docs.python.org/3/library/datetime.html#timedelta-objects)
with helper methods).

This PR introduces the new types and converts all usages of the existing
constants with it. Future PRs may work to move the clock methods to also
use it (e.g. `call_later` and `looping_call`).

Reviewable commit-by-commit.
This commit is contained in:
Erik Johnston
2025-11-26 10:56:59 +00:00
committed by GitHub
parent 2741ead569
commit b74c29f694
15 changed files with 95 additions and 93 deletions

1
changelog.d/19223.misc Normal file
View File

@@ -0,0 +1 @@
Move towards using a dedicated `Duration` type.