[lexical-mdast] Bug Fix: Leave a typed __init__ as text instead of a bold word #9921
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 313 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.344
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #9921"
general
weight: 0.35
potatowagon
Description
With
MdastShortcutsExtension, typing a Python name such as__init__or__main__in a sentence deletes the underscores and bolds the word as the closing__is typed, so "Edit the__init__file" reads "Edit the init file".The typed shortcut converts whatever construct micromark sees closing at the caret, and CommonMark reads
__init__as strong emphasis aroundinit. Import has to read it that way, but in prose a__run around a single word of ASCII letters, digits and underscores is more often a name than a bold word;snake_caseandx__init__already stay as typed because_runs don't open inside a word.MarkdownStreamScanner.scanInlinenow leaves strong emphasis alone when its delimiters are__and it holds one such word.init,__two words__and_init_still convert, and Markdown import is unchanged. A writer who wants one bold word typeswordor uses the bold command. Only the construct that closes at the caret is checked, so a name inside another construct, such asthe __init__, still loses its underscores when the outer delimiter is typed, as it does onmain.Test plan
Before
The new tests on
main:After
The new tests also check that the typed text exports with its underscores escaped (
the \_\_init\_\_).pnpm run ci-check(TypeScript, Flow, Prettier, ESLint and the changeset check) passes. Not run in a browser: the change is in the scanner the typed shortcut calls, which these tests drive one typed character at a time.