Vendor CPython's textwrap #1301
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 507 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.373
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1301"
general
weight: 0.35
rewitt94
Stacked on #1298: that PR's branch lives in a fork, so the base here is \
main\and the diff also shows its commits. Only the last two commits are new:Add str.translate, str.maketrans and re.VERBOSE\Vendor CPython's textwrap\What
\
import textwrap\runs CPython 3.14's own \Lib/textwrap.py\.str.translate\/ \str.maketrans\(new \types/str_translate.rs\), matching CPython's behaviour and error messages. The table is looked up with generic subscription, and the result is built with \StringBuilder\.re.VERBOSE\/ \re.X\exposed, and included in the pattern repr.0003-textwrap-no-del\: Monty does not parse \del\yet (#1032), and cannot read a builtin method without calling it (\patsearch = pattern.search\).limitations/\updated.Divergences (documented)
TextWrapper.word_punct\, \letter\, \nowhitespace\and \whitespace\stay as class attributes.translate\mapping to a surrogate raises \ValueError\, since Monty strings cannot hold lone surrogates.bytes.translate\/ \bytes.maketrans\are not implemented.Tests
New \
str__translate\and \textwrap__module\cases and \re.VERBOSE\asserts in \re__basic\, run on Monty and CPython. \cargo nextest -p monty -p monty-type-checking -p monty-types\, \make lint-rs\, \make check-stdlib\, \make check-typeshed\and \branch_diff.py --check\pass.<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Vendors CPython's own pure-Python
textwrap.pyand its upstream test suite, soimport textwrapworks without a Rust port, and adds thestr.translate/str.maketransmethods andre.VERBOSE/re.Xthat they need. The module is embedded in the binary and runs like a file module: compiled per session, cached by name, with no OS call.Infrastructure
crates/monty/stdlib/vendor.tomlpins CPython v3.14.10;make vendor-stdlibdownloads the files and LICENSE, appliespatches/*.patch, and generates the embedded source table.make check-stdlibruns in CI and fails if vendored files drift from the pinned release.make stdlib-candidatesreports which stdlib modules the current binary can load and the first blocker of each.test_textwrap.pytests run on Monty and CPython; the shared unittest patch dropswith_traceback(), which Monty exceptions lack, and each class lists its test methods since Monty has nodir().Divergences
delnot parsing (#1032) — the class-bodydelis dropped anddel chunks[-1]becomes.pop()— and bound builtin methods not being readable without a call;dedent's error names the type via__name__since Monty types have no__qualname__.str.translatebuilds its output through a single memory-checked path, so both mapped values and unmapped misses stay within the resource limits, and validates its arguments before copying the receiver, so an invalid call on a string too large to copy raisesTypeErrorrather thanMemoryError.ValueError, since Monty strings cannot hold lone surrogates;bytes.translate/bytes.maketransare not implemented.<sup>Written for commit 9889c77a05b515d40349225caecb3a3acda3a4ad. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/1301?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. -->