Reject a script path that collides with the type stubs file #967
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.44) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 252 lines diff across 3 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.331
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #967"
general
weight: 0.35
davidhewitt
Fixes #717
If
script_nameisrepl_type_stubs.pyi, the script gets written over the stubs file and ends up importing itself. #756 stopped the panic, but the type check result is still wrong: names from the stubs are reported as undefined, plus a "Cannot redefineT".Now
TypeChecker::runreturns an error when the script and the stubs resolve to the same file. I compare files and not strings, so./repl_type_stubs.pyiand similar paths are caught too.The host sees it as "type checker failed". If you'd rather have it fail at
Configure, I can move the check there.Added a test in monty-type-checking and a subprocess test with the repro from the issue, both fail on main. fmt, clippy and the rust tests pass, I didn't run the python tests.
<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Rejects scripts whose path resolves to the same file as the type stubs, which previously caused the script to overwrite the stubs and import itself, making stub names undefined and spans underflow.
./repl_type_stubs.pyiandsub/../repl_type_stubs.pyiare also caught.<sup>Written for commit 06815adbbdee04955733acc45a26b5c10de635e3. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/967?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->