Allow `list`, `tuple`, `...` constructors to suspend #1479
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 393 lines diff across 4 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.358
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1479"
general
weight: 0.35
jaheba
Collection constructors currently raise
NotImplementedErrorwhen a custom iterator, generator, or unread file needs a host call while it is being consumed. For example,list(open(path))andshlex.split(open(path))fail on an unread file.Allow
list,tuple,set,frozenset,dict,bytes,deque,Counter, anddefaultdictconstructors to suspend while iterating. Keep synchronous paths for known safe inputs; the other paths use frozen frames that survive session dumps. Set insertion, dict pair validation, byte conversion, and counting happen as items arrive so errors stop the source before it advances again. Synchronous callbacks within these operations retain their existing limitations.Tuple and frozenset construction use temporary mutable collections; bytes construction uses a temporary byte buffer.
Tests:
cargo test -p monty --features memory-model-checksmemory-model-checks(831 passed)cargo clippy -p monty --all-targets --features memory-model-checks -- -D warningsRelated: #1416, #1475.
<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
list(),tuple(),set(),frozenset(),dict(),bytes(),collections.deque(),collections.Counter(), andcollections.defaultdict()constructors now suspend while consuming iterables that need host calls, so patterns likelist(open(path))work on unread files instead of raisingNotImplementedError.sync_iterable, dict sources, and exact-type passthroughs (tuples, frozensets, bytes) never enter a Python frame.mapandfiltercallbacks can now suspend when driven by a collection constructor,for, orfunctools.reduce();sorted(),sum, anditertoolsadaptors still cannot.tuple(),frozenset(), andbytes()build through temporary mutable collections on the suspendable path. New tests cover incremental errors and dump/restore for every constructor.test-hooks-gatedlist._sync()so tests can keep exercising synchronous collection now thatlist()suspends; CI enables thetest-hooksfeature, and thepyattrsmacro accepts#[cfg]-gated attributes.<sup>Written for commit a06516dadd5439e728578de1f9ce3e2885246ed6. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/1479?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>
<!-- End of auto-generated description by cubic. -->