Add the `zoneinfo` module #1176
All Vouch review confidence checks passed
Residual risk 0.34 = Change Risk (0.57) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 572 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.380
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1176"
general
weight: 0.35
samuelcolvin
Adds the
zoneinfomodule and integratesZoneInfointodatetime.ZoneInfo(key)resolves an IANA key against the tz database the worker already carries (jiff's bundled tzdb, the same sourceOsPolicy::timezoneuses), with CPython's key validation andZoneInfoNotFoundErrormessage.available_timezones()returns the set of keys;ZoneInfo.no_cache()andZoneInfo.clear_cache()exist for compatibility.utcoffset(dt),tzname(dt),dst(dt)andfromutc(dt)follow CPython; a wall clock in a DST gap takes the pre-transition offset, as CPython'sfold=0does.In
datetime, aZoneInfoworks astzinfofor construction,replace,combine,now(tz),astimezone,utcoffset/tzname/dst,timetz()and timedelta arithmetic.The offset and abbreviation in force at each wall clock are resolved on demand and the zone object stays as
dt.tzinfo.Two datetimes sharing a
tzinfoobject subtract and compare by wall clock, as in CPython.monty-typesgainsSandboxTimeZone::dst_seconds,available_namesandinfo_for_localto back this.Divergences recorded in
limitations/zoneinfo.mdandlimitations/datetime.md:ZoneInfoNotFoundErroris bound toKeyErrorZoneInfo('UTC') is ZoneInfo('UTC')isFalse(==is by key)ZoneInfo.from_file()is not implemented;reset_tzpath/TZPATHare absentdatetime.now(ZoneInfo(...))under theCallHostclock policy raisesNotImplementedErrortime(tzinfo=ZoneInfo(...))raisesTypeError, since a time has no date to resolve the zonefoldis not read, so ambiguous wall clocks resolve to the first occurrencedst()is approximated as the difference from the zone's standard offset that yearModule registered in
limitations/modules.md,docs/limitations/index.md,SANDBOX_MODULE_NAMES, the JS external-module list andbinary_serde.rs; theTypefingerprint andbuiltin_type_serialization.txtfixture are extended.Tests in
zoneinfo__module.py(skip-cpython-windows, which has notime.tzset) plus additions to the datetime cases.Part of the set of PRs for the stdlib gaps reported by a user running Monty as an agent code-mode sandbox.
🤖 Generated with Claude Code
https://claude.ai/code/session_018zfZ5wd33kjDtV7BoUUV2T
<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Adds the
zoneinfomodule withZoneInfoandavailable_timezones(), and integratesZoneInfoas atzinfofordatetime. Offsets and abbreviations are resolved on demand from the worker's bundled tz database, and datetimes sharing aZoneInfoobject subtract and compare by wall clock, as in CPython.Notable divergences:
ZoneInfoNotFoundErrorisKeyError; there is no instance cache,from_file(),TZPATH, orreset_tzpath(), andclear_cache()is a no-op.foldis ignored, ambiguous wall clocks take the first occurrence, anddst()is approximated from the year's standard offset.datetime.now(ZoneInfo(...))raisesNotImplementedErrorunder thecall_hostclock policy.time(tzinfo=ZoneInfo(...))raisesTypeError, since a bare time has no date to resolve the zone.ZoneInfocannot cross the host boundary; an awaredatetimeis serialized with the fixed offset and abbreviation in force at that instant.<sup>Written for commit 2f708f6e792883ae9cf99ce526db2e873c20f4f5. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/1176?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/pydantic/monty/1176?returnTo=https%3A%2F%2Fgithub.com%2Fpydantic%2Fmonty%2Fpull%2F1176&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->