Skip to content

NAS-140909 / 27.0.0-BETA.1 / remove isodate dependency#357

Merged
yocalebo merged 2 commits into
masterfrom
rem-isodate
May 5, 2026
Merged

NAS-140909 / 27.0.0-BETA.1 / remove isodate dependency#357
yocalebo merged 2 commits into
masterfrom
rem-isodate

Conversation

@yocalebo

@yocalebo yocalebo commented May 5, 2026

Copy link
Copy Markdown
Contributor

Replaces the isodate third-party package with builtin Python functionality. The package was used in only three files for two functions, both easily covered by the standard library now that the project requires Python 3.11+.

  • Added a small parse_duration helper in zettarepl/utils/datetime.py. It accepts ISO 8601 durations restricted to weeks, days, hours, minutes, and seconds, which is the full set of components representable as a timedelta and the only set ever used in this codebase.
  • Replaced isodate.parse_duration calls in zettarepl/snapshot/task/task.py and zettarepl/replication/task/retention_policy.py with the new helper.
  • Replaced isodate.parse_time calls in zettarepl/scheduler/cron.py with the stdlib datetime.time.fromisoformat, which handles every begin/end value the project uses.
  • Dropped isodate from setup.py and removed the matching mypy override from pyproject.toml.

The primary caller is the TrueNAS middleware. In middlewared/plugins/zettarepl.py, lifetime_iso8601 always emits durations of the form PT<int>S. Even MONTH and YEAR units are pre-flattened to days at the middleware layer (30 and 365 days respectively) before being formatted, so ISO year and month components never reach zettarepl. The begin and end schedule values are likewise emitted as plain HH MM strings.

The existing lifetime type annotation is timedelta, which means year and month durations were already implicitly unsupported. Sorting them in CustomSnapshotRetentionPolicy would have failed because isodate.Duration does not compare with timedelta. The new helper rejects those components explicitly rather than silently producing a value that breaks downstream code.

The hand-written YAML configs that appear in the integration tests use only P1D, P14D, P30D, P7W, and PT1H, all of which the new parser handles.

  • All 145 unit tests pass.
  • mypy --strict reports no issues on the four changed source files.

@yocalebo yocalebo requested review from a team and themylogin May 5, 2026 14:38
@bugclerk bugclerk changed the title remove isodate dependency NAS-140909 / 27.0.0-BETA.1 / remove isodate dependency May 5, 2026
@bugclerk

bugclerk commented May 5, 2026

Copy link
Copy Markdown

@yocalebo

yocalebo commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

time 00:45

@yocalebo yocalebo merged commit 47b4b91 into master May 5, 2026
1 check passed
@yocalebo yocalebo deleted the rem-isodate branch May 5, 2026 15:58
@bugclerk

bugclerk commented May 5, 2026

Copy link
Copy Markdown

This PR has been merged and conversations have been locked.
If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

@truenas truenas locked as resolved and limited conversation to collaborators May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants