Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.12
rev: v0.15.20
hooks:
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -19,7 +19,7 @@ repos:
args: [--fail-under=24, localpost]

- repo: https://github.com/crate-ci/typos
rev: v1.46.1
rev: v1
hooks:
- id: typos

Expand All @@ -40,7 +40,7 @@ repos:
- id: validate-pyproject

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.13
rev: 0.11.26
hooks:
- id: uv-lock

Expand Down
6 changes: 3 additions & 3 deletions localpost/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,18 +202,18 @@ def ensure_td(value: timedelta | str, /) -> timedelta:
try:
import pytimeparse2 # noqa: PLC0415

use_dateutil = pytimeparse2.HAS_RELITIVE_TIMEDELTA
use_dateutil = pytimeparse2.HAS_RELATIVE_TIMEDELTA
try:
# Make sure to get timedelta, not relativedelta from dateutil
pytimeparse2.HAS_RELITIVE_TIMEDELTA = False
pytimeparse2.HAS_RELATIVE_TIMEDELTA = False
# ``as_timedelta=True`` makes ``parse`` return ``timedelta``
# exclusively, but the stubs still expose ``int | float | timedelta``.
result = cast("timedelta | None", pytimeparse2.parse(value, as_timedelta=True))
if result is None:
raise ValueError(f"Invalid time period: {value!r}")
return result
finally:
pytimeparse2.HAS_RELITIVE_TIMEDELTA = use_dateutil
pytimeparse2.HAS_RELATIVE_TIMEDELTA = use_dateutil
except ImportError:
raise ValueError("pytimeparse2 package is required to parse a time period string") from None
raise ValueError(f"Invalid time period: {value!r}")
Expand Down
Loading