Skip to content

fix(python): no probe on lines in the body of if TYPE_CHECKING: (#14156) - #14455

Merged
EffortlessSteven merged 6 commits into
mainfrom
claude/project-thread-w844ql
Nov 13, 2026
Merged

EffortlessSteven merged 6 commits into
mainfrom
claude/project-thread-w844ql

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Requested by Steven Zimmerman · project thread

Summary

  • The Python preview probed each changed line in the body of if TYPE_CHECKING:. That body never runs, so an import or type alias edited, added or deleted there changes no behavior.
  • type_checking_block.rs reads the block ranges from the parsed module and feeds them into the existing no-behavior decision on both sides of the diff.
  • Found by running ripr check on real commits of well-known Python projects (read-only clones). On 120 commits of requests, flask, click, attrs, httpx and rich, 20 findings on 9 commits are gone, every one inside such a block, and none are added. requests 5691f59 went from 8 findings to 1.

Closes #14156

Source review: SOURCE_REVIEW_READY 12dd7b6

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge,
    dependency, or repo-ops development for ripr-swarm

Source-of-truth Links

Proposal: n/a
Spec: n/a
ADR: n/a
Plan item: n/a
Governing issue or accepted claim: #14156
Acceptance delta (one sentence): a changed line in the body of a recognised if TYPE_CHECKING: block yields no probe, and runtime code moved into one, the else branch, and a rebound flag keep their probes.

Candidate Relationships

Candidate branch (GitHub PR head is authoritative after publication): claude/project-thread-w844ql
Stack parent or prerequisite PR (if any): none (the branch carries a merge of main after #14153; the diff against main is this fix only)
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): none
Accepted winner and losing candidate disposition (when decided): n/a

Scope

  • python/type_checking_block.rs (new): type_checking_only_line_ranges. The flag must be bound by from typing import TYPE_CHECKING, from typing_extensions import TYPE_CHECKING or TYPE_CHECKING = False; typing.TYPE_CHECKING needs import typing [as x]. Any other binding of the name (a statement or a := target), a star import from another module, or a match statement makes the file unreadable and returns no ranges. The range is the block body, plus the if line when the test is on one line; a body on the if line itself and the else branch are never included.
  • python.rs: ranges for the new and old file; new lines in a block join the quiet-line run and the classifier context.
  • python/classify.rs: new_line_type_checking_only / old_line_type_checking_only join the docstring flags in the no-op test, so a change is dropped only when both sides are type-checking-only or non-behavioral.
  • python/deleted_lines.rs: a deleted line from such a block is not a removed behavior line.
  • python/type_checking_block_tests.rs (new): 9 tests, 7 through PythonAdapter::analyze_diff.
  • Review repairs (fcc5b01d, from Devin): an added block line is quiet for its run only when its paired old line also did not run; a write or del of a TYPE_CHECKING attribute or name marks the file unread; a workspace with its own top-level typing/typing_extensions module reads no block.
  • Review repair (12dd7b64, from the source review of fcc5b01d): a named expression whose target is the flag or a typing alias ((TYPE_CHECKING := True), if (t := load()):) marks the file unread; it is found in the token stream, so every expression position is covered. The moved-line test now uses a fixture whose old side reconstructs and asserts the exact probe set.
  • changelog.d/python-type-checking-block-14156.md.

Scope Classification

  • One production behavior

Production delta:

  • No probe on a changed line inside the body of a recognised if TYPE_CHECKING: block.

Evidence/support delta:

  • Regression tests, positive and negative; changelog fragment.

Single acceptance criterion:

  • An alias edited, added or deleted under if TYPE_CHECKING: yields no finding, while runtime lines beside it keep theirs.

Non-goals:

  • Other always-false guards (if False:, if 0:), typing.TYPE_CHECKING reached through other import shapes, the else branch, TypeScript import type.

Support-tier Impact

  • none

Claim/proof notes:

  • Python stays preview.

Policy Impact

  • none

Ledger or exception notes:

  • none

Proof

cargo fmt --check
cargo test -p ripr --lib python::type_checking_block_tests   # 9 passed
cargo test -p ripr --lib python::                            # head 12dd7b64: 2,091 passed, 1 ignored
# removal experiments: each repair disabled in turn, focused suite rerun
ripr check --base <c>~1 --committed --format json            # 120 real Python commits, before and after
cargo xtask precommit                                        # pass

Result, failures, or skipped proof:

  • Focused tests: 9 pass on 12dd7b64.
  • Removal experiments on 12dd7b64: disabling the := check turns type_checking_block_shapes red; dropping the paired-line condition in python.rs turns runtime_code_moved_into_a_block_beside_a_runtime_edit_keeps_probe red (it asserts the reconstructed old side and the probe set [5, 6]).
  • Removal experiment for the shadowed-typing gate (fcc5b01d): workspace_typing_module_keeps_block_probes goes red.
  • Removal experiment (both range computations in python.rs forced empty): 4 tests go red (edited_alias_in_a_type_checking_block_is_not_probed, added_type_checking_block_is_not_probed, line_deleted_from_a_type_checking_block_is_not_probed, runtime_line_beside_a_type_checking_edit_keeps_its_probe); the replaced-runtime control and the shape table stay green, as they should on both sides.
  • Real commits: 898 findings before, 878 after; 20 gone, 0 added. Every gone finding was checked against the commit's source and sits in an if TYPE_CHECKING: / if typing.TYPE_CHECKING: / if t.TYPE_CHECKING: block (httpx 1805ee0, 2ea2286; requests 3816cfa, 5691f59, 84d10f0, e50e594, e511bc7; rich b502fbd; click 22177f8).
  • cargo xtask precommit: pass on 8ab2a301, fcc5b01d and 12dd7b64. A first run failed check-local-context on a fixture string that read as a Windows path (\nclass C:\n); the fixture class was renamed.
  • Hosted qualification on the exact head: requested with merge-ready.

Continuation record

Owner / governing claim: project thread "Try RIPR on Python and TypeScript repos" / #14156
Candidate: this PR / branch claude/project-thread-w844ql / basis main bc82bf22
Review: source review of fcc5b01d (walrus rebind, moved-line test) repaired in 12dd7b64; Devin's 4 findings answered (3 repaired), threads resolved; CodeRabbit and Gemini returned quota notices
Validation: see Proof; hosted qualification requested
Dependency: none (#14157 follows on its own branch after this lands)
Next: source review, merge-ready, inspect results, enqueue / this thread

Claim Boundary

  • May be claimed: changed lines in the body of a recognised if TYPE_CHECKING: block no longer produce findings in the Python preview.
  • Must not be claimed: anything about test adequacy or runtime outcomes; static evidence only. A file that rebinds TYPE_CHECKING (including by :=), imports it from elsewhere, or uses match is read as before.

Rollback

  • Revert this squash commit; no schema, config or generated artifact changes.

Spec-Test-Code Traceability

  • Spec: n/a
  • Tests: crates/ripr/src/analysis/language/python/type_checking_block_tests.rs
  • Code: crates/ripr/src/analysis/language/python/type_checking_block.rs, python.rs, python/classify.rs, python/deleted_lines.rs
  • Golden outputs: none changed
  • Metrics: none
  • ADR/learning: none

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.
  • Unknowns include stop reasons where applicable.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.
  • Errors are reported with actionable context.

Gates

  • cargo fmt --check
  • cargo xtask precommit (see Proof for the heads)

🤖 Generated with Claude Code

https://claude.ai/code/session_016EQRVmHPS5rKE967z5W6be

…ction (#14097)

A new function, method or arrow whose signature a formatter wrapped over
several lines got one finding per physical signature line: the opening
line, each parameter line (read as field_construction) and the `): T {`
closer (read as predicate). The one-line spelling of the same signature
already yields no header probe, so the result depended on line width.

Read the header as one unit: from the owner's first line to the first
line ending in `{` outside the parameter list, accepted only when the
joined text passes is_signature_opening_line. A default value, a
destructuring default, a parameter property, a computed key or a
decorator keeps every line probed, as do a constructor, a changed
signature of an existing owner, a header that is not all added lines,
and a body with no added probe line.

On 100 real commits of zod, hono, date-fns, axios and TanStack query
this removes 397 signature-line findings (380 date-fns, 17 hono).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016EQRVmHPS5rKE967z5W6be
…des a body line (#14097)

The wrapped-header reader counts round brackets only to pick the line
where the parse is tried. Pin the consequence of a miscount: an unclosed
`(` in a header comment costs a missed header (its lines keep their
probes), a body comment that rebalances the count does not make a body
line part of the header, a stray `)` still reads the real header, and a
`)` inside a default string keeps the header probed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016EQRVmHPS5rKE967z5W6be
…4156)

The body of `if TYPE_CHECKING:` (or `if typing.TYPE_CHECKING:`) never
runs, so an import or alias edited, added or deleted there changes no
behavior. The Python preview probed each such line.

`type_checking_block.rs` reads the block ranges from the parsed module
and returns nothing when the flag's binding is not the one from
`typing`/`typing_extensions` (or the `TYPE_CHECKING = False` idiom).
The ranges feed the existing no-behavior decision on both sides of the
diff, so runtime code moved into such a block keeps its probe, and the
`else` branch is never included.

Found on real commits of requests, click, httpx and rich: 20 findings
on 9 commits gone, none added, across 120 Python commits.

Closes #14156

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016EQRVmHPS5rKE967z5W6be
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@EffortlessSteven EffortlessSteven self-assigned this Nov 12, 2026
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 144 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 2e41a3c4-cf79-432a-8227-c787ad8280c9
Commits

Reviewing files that changed from the base of the PR and between bc82bf2 and 12dd7b6.

Files selected for processing: 6

  • changelog.d/python-type-checking-block-14156.md
  • crates/ripr/src/analysis/language/python.rs
  • crates/ripr/src/analysis/language/python/classify.rs
  • crates/ripr/src/analysis/language/python/deleted_lines.rs
  • crates/ripr/src/analysis/language/python/type_checking_block.rs
  • crates/ripr/src/analysis/language/python/type_checking_block_tests.rs
Pre-merge checks: Inconclusive 2

Failed Failed checks: 2 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Description check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 4 potential issues.

Devin Review

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

ripr static exposure check

Commit 12dd7b64f2d3 · run · advisory, static evidence only (not a mutation run).

#ripr agent static-advisory base=bc82bf22977ddc2710fc1dd16c4658eec722b155 findings=250 gaps=35 infection_unknown=6 propagation_unknown=5 reachable_unrevealed=25 static_unknown=59 weakly_exposed=155
weakly_exposed|crates/ripr/src/analysis/language/python/classify.rs:276|no_behavior.new_line_in_docstring \|\| no_behavior.new_line_type_checking_only|missing=Check unconfirmed: no supported assertion that distinguishes the changed behavio…|test=t1|id=probe:crates_ripr_src_analysis_language_python_classify.rs:predicate:c7b3581b
stages=reach:yes,infect:yes,propagate:yes,observe:yes,discriminate:weak
weakly_exposed|crates/ripr/src/analysis/language/python/classify.rs:280|no_behavior.old_line_in_docstring \|\| no_behavior.old_line_type_checking_only|missing=Check unconfirmed: no supported assertion that distinguishes the changed behavio…|test=t1|id=probe:crates_ripr_src_analysis_language_python_classify.rs:predicate:c6178729
stages=reach:yes,infect:yes,propagate:yes,observe:yes,discriminate:weak
reachable_unrevealed|crates/ripr/src/analysis/language/python/type_checking_block.rs:106|self.flag_is_typing = true|missing=self.flag_is_typing = true|test=t2|id=probe:crates_ripr_src_analysis_language_python_type_checking_block.rs:field_construction:2d4ac5d5
stages=reach:weak,infect:yes,propagate:yes,observe:no,discriminate:no
reachable_unrevealed|crates/ripr/src/analysis/language/python/type_checking_block.rs:108|self.unreadable = true|missing=self.unreadable = true|test=t2|id=probe:crates_ripr_src_analysis_language_python_type_checking_block.rs:field_construction:1231a035
stages=reach:weak,infect:yes,propagate:yes,observe:no,discriminate:no
reachable_unrevealed|crates/ripr/src/analysis/language/python/type_checking_block.rs:112|self.other_names.insert(name.id.to_string())|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t2|id=probe:crates_ripr_src_analysis_language_python_type_checking_block.rs:call_deletion:3ff0ef0b
stages=reach:weak,infect:yes,propagate:yes,observe:no,discriminate:no
reachable_unrevealed|crates/ripr/src/analysis/language/python/type_checking_block.rs:112|self.other_names.insert(name.id.to_string())|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t2|id=probe:crates_ripr_src_analysis_language_python_type_checking_block.rs:side_effect:21fe5415
stages=reach:weak,infect:yes,propagate:yes,observe:no,discriminate:no
reachable_unrevealed|crates/ripr/src/analysis/language/python/type_checking_block.rs:116|self.bind_target(element, false)|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t2|id=probe:crates_ripr_src_analysis_language_python_type_checking_block.rs:call_deletion:c02b2fe3
stages=reach:weak,infect:yes,propagate:yes,observe:no,discriminate:no
reachable_unrevealed|crates/ripr/src/analysis/language/python/type_checking_block.rs:121|self.bind_target(element, false)|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t2|id=probe:crates_ripr_src_analysis_language_python_type_checking_block.rs:call_deletion:c02b2fe3.2
stages=reach:weak,infect:yes,propagate:yes,observe:no,discriminate:no
reachable_unrevealed|crates/ripr/src/analysis/language/python/type_checking_block.rs:128|self.unreadable = true|missing=self.unreadable = true|test=t2|id=probe:crates_ripr_src_analysis_language_python_type_checking_block.rs:field_construction:1231a035.2
stages=reach:weak,infect:yes,propagate:yes,observe:no,discriminate:no
t1=crates/ripr/src/analysis/language/python/classify/tests.rs:4341 a_class_header_lookalike_inside_a_multiline_string_keeps_its_probe unknown miss=assertion_inert
t2=crates/ripr/src/analysis/language/python/type_checking_block_tests.rs:128 added_type_checking_block_is_not_probed unknown miss=assertion_inert
+26 more gaps not shown; `--format json` lists all
limits=infection_unknown:6,propagation_unknown:5,static_unknown:59,weakly_exposed:145
next=ripr explain --root . --base bc82bf22977ddc2710fc1dd16c4658eec722b155 --committed --mode draft --format agent probe:crates_ripr_src_analysis_language_python_classify.rs:predicate:c7b3581b
verify=refused|outcome=complete_with_findings|findings=250|exposed=0|reason=gaps_remain

Took 292s.

)

Review repairs from Devin on #14455:

- An added line in a block counts as quiet for its run only when the
  line it replaced did not run either. Runtime code moved into a block
  beside a runtime edit now keeps its probe.
- A write or `del` of a `TYPE_CHECKING` attribute (for example
  `typing.TYPE_CHECKING = True`) or of the bare name marks the file
  unread.
- A workspace with its own top-level `typing` or `typing_extensions`
  module (at the root or under `src/`) reads no block, since an import
  may resolve there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016EQRVmHPS5rKE967z5W6be

Copy link
Copy Markdown
Member Author

Answers to the four Devin findings on 3ea9df9a. Three are repaired in fcc5b01d; one stays as is, with the reason below.

  1. Moved runtime line loses its finding (python.rs 2199, fix(python): no probe on lines in the body of if TYPE_CHECKING: (#14156) #14455 (comment)): valid. The run-coverage closure now treats an added block line as quiet only when its paired old line was also non-running (old block, docstring, import, comment or structural line). Pinned by runtime_code_moved_into_a_block_beside_a_runtime_edit_keeps_probe, which goes red when that condition is removed.
  2. Patched typing flag hides runtime edits (type_checking_block.rs 93, fix(python): no probe on lines in the body of if TYPE_CHECKING: (#14156) #14455 (comment)): valid. Any assignment, augmented or annotated assignment, or del whose target is a TYPE_CHECKING attribute now marks the file unread, and del TYPE_CHECKING does the same for the bare name. Two new rows in type_checking_block_shapes.
  3. Shadowed typing module hides live changes (type_checking_block.rs 115, fix(python): no probe on lines in the body of if TYPE_CHECKING: (#14156) #14455 (comment)): valid. A workspace with its own top-level typing or typing_extensions module (file or package, at the root or under src/) now reads no block in any file. A module of that name inside a package does not shadow an absolute import and is left alone. Pinned through the adapter by workspace_typing_module_keeps_block_probes (a workspace typing.py with TYPE_CHECKING = True; red without the check) and by workspace_typing_shadow_paths.
  4. New suppression lacks required spec mapping (type_checking_block_tests.rs 101, fix(python): no probe on lines in the body of if TYPE_CHECKING: (#14156) #14455 (comment)): no change. No spec governs the Python preview's no-behavior line guards. The guards for docstrings, comments, annotation-only edits and wrapped headers live in code and tests only, and none of the last eight merged Python adapter fixes touched docs/specs or .ripr/traceability.toml. cargo xtask check-traceability runs inside cargo xtask precommit, which passed on this change. The tests module path is named in the PR body's traceability section.

Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOURCE_REVIEW_READY

Source review of head fcc5b01d4883b72ed9f7e26f849cb774805a9a50 (basis main bc82bf22; the diff against main is this fix only: 6 files).

Read in full: type_checking_block.rs, type_checking_block_tests.rs, the python.rs wiring (new and old ranges, the shadowed-typing gate, the quiet-run closure, the two context fields, OldSideRanges), the no-op test in classify.rs, is_removed_behavior_line in deleted_lines.rs, and the changelog fragment.

Checked:

  • Flag recognition reads the flag as false only when nothing in the file can make it true. The bare name counts only after from typing import TYPE_CHECKING, from typing_extensions import TYPE_CHECKING or TYPE_CHECKING = False. Any other binding of the name (assignment, del, parameter, global, loop target, except ... as, def or class name), any write to a TYPE_CHECKING attribute such as typing.TYPE_CHECKING = True, a star import from another module, or a match statement marks the file unread. The attribute form needs import typing or import typing_extensions under a name nothing else rebinds.
  • A workspace with its own top-level typing or typing_extensions module, at the root or under src/, reads no block at all.
  • Range shape: the block body, plus the if line only when the test ends on that line. A body on the if line itself is never counted; elif and else are walked as ordinary code; if not TYPE_CHECKING: and compound tests are not the flag test.
  • Both sides of the diff: an added block line counts as quiet for its run only when its paired old line was also non-running, and the classifier drops a change only when both sides are type-checking-only or non-behavioral. Runtime code moved into a block keeps its probe, alone or beside a runtime edit. A deleted line from an old block is not a removed behavior line.
  • Tests: 9, all but the two table tests through PythonAdapter::analyze_diff on a fixture with a runtime caller and a test. Removal experiments: forcing the block ranges empty turns 4 tests red; dropping the paired-line condition and the shadowed-typing gate turns runtime_code_moved_into_a_block_beside_a_runtime_edit_keeps_probe and workspace_typing_module_keeps_block_probes red.
  • The four Devin findings on 3ea9df9a: three repaired in fcc5b01d with the tests above; the spec-mapping one answered in the conversation. All four threads are resolved. CodeRabbit and Gemini returned quota notices, so there is no review from them.
  • Real commits: 20 findings gone on 9 commits of requests, httpx, rich and click, each checked to sit in such a block; none added.

Local proof on this head: cargo test -p ripr --lib python:: 2,091 passed, 1 ignored; cargo xtask precommit pass (digest sha256:2830fad4...).

Static evidence only; Python stays preview. Hosted qualification on this exact head is next.


Generated by Claude Code

Copy link
Copy Markdown
Member Author

cargo-deny (Security workflow, run 43151707182) is red on fcc5b01d because of RUSTSEC-2026-0486, an unsound-advisory on rustix 1.1.5 in Cargo.lock. That comes from main and not from this PR, which touches no dependency or lock file. The fix is already open as #14240 (rustix 1.1.5 to 1.1.6). cargo-deny is not the required check for main (that is Ripr Rust Small Result), so I am not widening this PR with the lock bump. Qualification on this head continues.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven added this pull request to the merge queue Nov 12, 2026

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEW_READY

Final pass on head fcc5b01d4883b72ed9f7e26f849cb774805a9a50 (basis main bc82bf22). The source review recorded on this same head at 03:58Z stands; the diff has not changed since.

Hosted evidence on this exact head:

  • Admit PR Candidate: success.
  • Rust tests shards 1 to 4 of 4 and Rust test shards verify: success.
  • Ripr Rust Small Result: success (05:32Z).
  • Ripr Windows Gate Result: success.
  • cargo-deny (Security workflow, not a required check) is red on RUSTSEC-2026-0486 for rustix 1.1.5, which comes from main's lock file; the bump is #14240. Explained in the conversation.

Review inputs: Devin's four findings on 3ea9df9a (three repaired with tests, one answered), all threads resolved; CodeRabbit and Gemini returned quota notices, so there is no review from them; the ripr comment on this diff is advisory static evidence.

Claim boundary unchanged: changed lines in the body of a recognised if TYPE_CHECKING: block yield no probe in the Python preview, and every case where the flag could be true keeps its probes. Static evidence only.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: BLOCK fcc5b01 — the recognizer misses a walrus rebind of the flag, so a block that runs at runtime is treated as type-checking-only and its changed lines are dropped.

Blocking finding: a walrus rebind is not read

type_checking_block.rs claims a closed recognizer ("no statement in the file may bind either name any other way"), and the PR's Claim Boundary says "A file that rebinds or patches TYPE_CHECKING ... is read as before." Bindings::read_statement has no arm for Stmt::Expr and does not read the test expression of Stmt::If/Stmt::While, so a named-expression target is never seen:

from typing import TYPE_CHECKING
(TYPE_CHECKING := True)
if TYPE_CHECKING:
    import a

Bindings records flag_is_typing = true from the import, never sees the walrus, and collect records lines 3-4 as type-checking-only. At runtime the walrus sets the flag true, so import a runs; a diff that edits that import is dropped as a no-op. The same holds for if (TYPE_CHECKING := True): followed by a later if TYPE_CHECKING:.

The repository already walks Expr::NamedExpr targets in source_facts.rs (collect_assignment_target_facts), so the fix is to walk expression trees for NamedExpr targets (and the tests of if/while/assert) and mark the file unreadable when the target is the flag or a typing alias, or to add a Stmt::Expr/test-expression walk. A test with the input above would pin it.

Non-blocking: the "moved" regression test does not exercise its named case

runtime_code_moved_into_a_block_beside_a_runtime_edit_keeps_probe adds lines 10-14 and removes lines 10 and 14. The harness takes each added line's text from PRICING_PY, so added line 10 is the alias line, not DISCOUNT = compute_discount(); the removed line 10 is also a block line. reconstruct_old_source returns None (the removed line 14 index is past the end after five added lines are removed), so old_type_checking_ranges is empty and the old line is treated as behavioral. The test is green because the old source is unavailable, not because the counterpart rule handled a runtime line moved into the block. The claim is covered by runtime_code_replaced_by_a_type_checking_line_keeps_probe (old runtime line, new block line, old source reconstructed), so this is a test-quality defect, not a second production defect. The assertion is also contains(&10) rather than an exact set.

Qualification the head still lacks

The current PR body has no Source review: REVIEW_READY fcc5b01d... line (the last "Admit PR Candidate" run finished at 05:32, before the body's 19:45 edit). A fresh admission run reads the body and would refuse; the review at this head is SOURCE_REVIEW_READY/REVIEW_READY, not the machine-readable body line.

What I checked

Read the full diff at fcc5b01: the new recognizer, the python.rs quiet-run and classifier wiring, deleted_lines.rs, and the nine tests. Checked the binding walker against Stmt variants and the repo's NamedExpr handling in source_facts.rs. No build, test, or mutation run; no checkout.

@EffortlessSteven
EffortlessSteven removed this pull request from the merge queue due to a manual request Nov 12, 2026
A named expression can rebind the flag or a typing module alias from any
expression (`(TYPE_CHECKING := True)`, an `if` test, a call argument).
The statement walk never saw those targets, so the block was still read
as type-checking-only. The token stream now finds every `name :=` whose
name is the flag or a typing alias, and such a file reads no block.

The moved-line test now uses a fixture whose old side reconstructs and
whose moved line shares an added run with a runtime edit, so it fails
without the paired-line condition, and it asserts the exact probe set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016EQRVmHPS5rKE967z5W6be

Copy link
Copy Markdown
Member Author

Answer to the source review of fcc5b01d (review 5881152069), repaired in 12dd7b64:

  1. Walrus rebind. Confirmed: (TYPE_CHECKING := True) and if (TYPE_CHECKING := True): were read as typing blocks. type_checking_block.rs now scans the token stream for a name := whose name is the flag or a typing module alias and reads no block in that file. A := target is always a bare name, so the token check covers every expression position (call arguments, comprehensions, if/while/assert tests) without walking each expression shape; the default lexer drops comments and bracketed line breaks, so a split target is still caught. Four new rows in type_checking_block_shapes: the statement, the if test, a comment between target and :=, and a rebound t alias. Removing the check turns that test red.
  2. Moved-line test. Correct, the old fixture did not reconstruct. The test now uses its own fixture: old line 5 Basket = list runs at module level, new line 5 is its block replacement, and line 6 edits RATE in the same added run. The test asserts that the old side reconstructs, the old and new block ranges, and the exact probe set [5, 6]. Dropping the paired-line condition in python.rs turns it red.
  3. Body line. Added a Source review: line for the new head.

Proof on 12dd7b64: focused 9 pass, Python adapter suite 2,091 pass (1 ignored), cargo xtask precommit pass.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOURCE_REVIEW_READY

Inspected on head 12dd7b64f2d32b4dcfd56355125179d15532ec11 (diff fcc5b01d..12dd7b64, plus the full PR diff against main):

  • type_checking_block.rs: rebinds_by_named_expression lexes the parsed file and refuses any name := whose name is TYPE_CHECKING or a recorded typing alias; a lexer error also refuses. It runs after the statement walk, so the typing aliases it checks are the complete set. A := target is always a bare name, so no expression position is missed.
  • Tests: four new negative shape rows (statement, if test, comment between target and :=, rebound alias). The moved-line test now reconstructs its old side, asserts old and new block ranges, and asserts the exact probe set [5, 6].
  • Removal experiments: the := check off turns the shape table red; the paired-line condition off turns the moved-line test red.
  • Proof: focused 9 pass, Python adapter suite 2,091 pass (1 ignored), cargo xtask precommit pass.

Hosted qualification for this head is still to run.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOURCE_REVIEW_READY
VERDICT: APPROVE 12dd7b6 — no blocking findings on this head.

The walrus blocker from my review at fcc5b01 is repaired. rebinds_by_named_expression lexes the file and treats any NAME := whose name is the flag or a typing-module alias as an unreadable binding, so type_checking_only_line_ranges returns no ranges and every line keeps its probe. The scan errs only toward keeping probes: a lexer error counts as rebinding, and a walrus in a nested scope costs suppression but never causes a wrong one. The lexer is built without full-lexer, so comments and non-logical newlines are dropped and a target split from := by a comment stays adjacent; the new shapes rows cover statement-level, in-test, comment-split and typing-alias walruses, and the rewritten moved-line test drives reconstruct_old_source and asserts the exact probed set [5, 6]. All four review threads are resolved.

Qualification still missing on this head: the Rust gates (Ripr Rust Small on GitHub Hosted / Rust gates and the four test shards) are pending; the queue must run them before landing.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEW_READY

Final pass on head 12dd7b64f2d32b4dcfd56355125179d15532ec11 (basis main bc82bf22). The source review on this head stands, and the second reviewer's pass on this head found nothing blocking.

Hosted evidence on this exact head: merge-ready run 43310998718 has Rust gates, all four test shards, the shard verify, and Ripr Rust Small Result all passing. The earlier run 43305911865 was cancelled when this one started, so its Result does not apply. All four review threads are resolved. CodeRabbit returned only quota and skip notices, so it gave no review.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven added this pull request to the merge queue Nov 12, 2026

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: APPROVE 12dd7b6 — no blocking findings on this head.

Refresh of my BLOCK at fcc5b01d. The blocking finding is repaired at this head.

The walrus rebind is now read. rebinds_by_named_expression (type_checking_block.rs:59) lexes the source and returns unreadable when a := follows a name that is the flag or a typing-module alias. That covers the exact input I named ((TYPE_CHECKING := True) before if TYPE_CHECKING:), a walrus in the if test itself, a target split from := by a comment inside brackets, and a walrus on import typing as t. The four new cases in type_checking_block_shapes pin each one. A lexer rejection also counts as unreadable, so the scan fails closed.

The test-quality defect is repaired. runtime_code_moved_into_a_block_beside_a_runtime_edit_keeps_probe now uses MOVED_PY, reconstructs the old source, asserts the old block is 3..=4 and the new block is 3..=5, and asserts the exact probe set [5, 6]. The moved line is now genuinely a runtime line moved into the block beside a behavioral edit, not a case that passed because the old source was unavailable.

Qualification. The PR body carries Source review: SOURCE_REVIEW_READY 12dd7b64..., and the latest routed run is green: Rust gates, all four test shards, shard verify, and Ripr Rust Small Result are SUCCESS. All four review threads are resolved.

Could not check: no local build, test, or mutation run; the analysis is static. No checkout, branch, or worktree was created.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEW_READY

Final pass on head 12dd7b64f2d32b4dcfd56355125179d15532ec11, restated so it is the latest review on this head. The second reviewer's 22:31Z pass on this head approves it.

Hosted evidence is unchanged: merge-ready run 43310998718 passed (Rust gates, four test shards, shard verify, Ripr Rust Small Result), and all four review threads are resolved.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOURCE_REVIEW_READY
VERDICT: APPROVE 12dd7b6

Reviewed head: 12dd7b6

Refresh of my BLOCK at fcc5b01d. The blocking finding is repaired at this head.

The walrus rebind is now read. rebinds_by_named_expression (type_checking_block.rs:59) lexes the source and returns unreadable when a := follows a name that is the flag or a typing-module alias. That covers the exact input I named ((TYPE_CHECKING := True) before if TYPE_CHECKING:), a walrus in the if test itself, a target split from := by a comment inside brackets, and a walrus on import typing as t. The four new cases in type_checking_block_shapes pin each one. A lexer rejection also counts as unreadable, so the scan fails closed.

The test-quality defect is repaired. runtime_code_moved_into_a_block_beside_a_runtime_edit_keeps_probe now uses MOVED_PY, reconstructs the old source, asserts the old block is 3..=4 and the new block is 3..=5, and asserts the exact probe set [5, 6]. The moved line is now genuinely a runtime line moved into the block beside a behavioral edit, not a case that passed because the old source was unavailable.

Qualification. The PR body carries the machine-readable source-review line for this head, and the latest routed run is green: Rust gates, all four test shards, shard verify, and Ripr Rust Small Result are SUCCESS. All four review threads are resolved.

Could not check: no local build, test, or mutation run; the analysis is static. No checkout, branch, or worktree was created.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Verification on current live head 12dd7b64f2d32b4dcfd56355125179d15532ec11: the requested walrus-rebind and moved-line repairs are already present, so no additional commit or PR-body edit was needed.

  • rebinds_by_named_expression scans the token stream and makes the file unreadable when the flag or a typing alias is rebound with :=.
  • The moved-line test reconstructs its old source and asserts the exact probe set [5, 6].
  • The body already carries its machine-readable source-review line, and the current head has green hosted Rust gates.

Focused proof on that exact head:

cargo test -j2 -p ripr --lib python::type_checking_block_tests
  9 passed, 0 failed (including all walrus shapes and the moved-line case)
git diff --check bc82bf22977ddc2710fc1dd16c4658eec722b155..HEAD
  exit 0

No label, queue, or merge action was taken. Temporary worktree and Cargo target were removed after verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python: lines under if TYPE_CHECKING: are probed as behavior (requests: 7 findings for a type-alias edit that never runs)

2 participants