Skip to content

fix(python): withhold probe for legacy object-only class header edits (#11888) - #11932

Merged
EffortlessSteven merged 1 commit into
mainfrom
cursor/python-object-base-guard-11888-ad4a
Oct 31, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
cursor/python-object-base-guard-11888-ad4a

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

Pyupgrade-style edits that only remove or add the legacy bare object base (or empty () before :) on a single-line class header are behavior-preserving. Route them through the existing annotation-only withhold in no_behavior.rs so class Box(object): → class Box: no longer reads exposed.

Source-of-truth Links

Governing issue or accepted claim: #11888

Acceptance delta (one sentence): A single-line Python class header change that only toggles the legacy object base or empty () emits no probe, matching annotation-only def withhold behavior.

Closes #11888

Scope Classification

  • One production behavior

Production delta: closed allow-list guard is_object_base_only_class_change consulted from is_annotation_only_def_change; classify.rs unchanged.

Evidence/support delta: unit guard cases and Box end-to-end test in python/tests.rs.

Proof

cargo test -p ripr object_base -- --nocapture
cargo test -p ripr annotation_only_detection_is_conservative -- --nocapture
cargo xtask precommit

Local precommit passed at e71003b7f2. No Python verdict-corpus golden changes.

Claim Boundary

Establishes: no-behavior withhold for sole object / empty-parens class header toggles on the same class name.

Does not establish: multi-base, metaclass, decorator, or multi-line header edits; runtime mutation outcomes.

Rollback

Revert the squash commit; legacy object-base class header edits resume emitting probes.

Open in Web Open in Cursor 

…#11888)

Add a closed allow-list in no_behavior.rs for pyupgrade-style
class X(object): / class X(): to class X: edits and route it through
the existing annotation-only def guard so classify.rs stays untouched.

Tests cover true/false guard cases and the Box end-to-end repro.

Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
@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!

@coderabbitai

coderabbitai Bot commented Oct 31, 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 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 149 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: 974e38b7-8809-44d2-9593-cfd255df42e4
Commits

Reviewing files that changed from the base of the PR and between fa621a3 and e71003b.

Files selected for processing: 2
  • crates/ripr/src/analysis/language/python/no_behavior.rs
  • crates/ripr/src/analysis/language/python/tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@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 (exact head e71003b7f2)

Disposition: REVIEW_READY for merge convergence pending hosted qualification.

Surfaces inspected: no_behavior.rs legacy class-base allow-list wired at top of is_annotation_only_def_change; classify.rs:294 path unchanged.

Oracle/tests: guard true/false matrix + Box end-to-end repro. No verdict-corpus golden drift.

Residuals: hosted CI pending on this head.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Merge-ready at head e71003b7f2. Initial required checks green (ub-review, wheel qualify lanes, security). REVIEW_READY self-review on file. Requesting late qualification via merge-ready label (add attempted; integration token may lack label permission — please apply label if missing). Do not merge from this agent run.

@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.

Independent review (fresh-context reviewer, head e71003b): REVIEW_INCOMPLETE

Inspected:

  • PR #11932 "fix(python): withhold probe for legacy object-only class header edits (#11888)", head e71003b7f2e55f47e3e1a99de79d1c4c1e630b9a, base fa621a32eaf4c3dc6c17119021ea943641696aef, non-draft, label merge-ready. Changed files: crates/ripr/src/analysis/language/python/no_behavior.rs (+96), crates/ripr/src/analysis/language/python/tests.rs (+61). Patches read from REST pulls/11932/files.
  • Semantic owner of the changed behavior: crates/ripr/src/analysis/language/python/no_behavior.rs:363-366 is_annotation_only_def_change, the single production decision point. Its only production consumer is crates/ripr/src/analysis/language/python/classify.rs:292-297, where the guard returns None for that changed line. classify.rs is unchanged by this PR, as the body states. The other apparent consumer, crates/ripr/src/analysis/language/python.rs:146-150, is a #[cfg(test)]-only re-export used by tests.rs.
  • New guard: no_behavior.rs:266-269 LegacyClassBaseShape, :271-301 legacy_class_header_shape, :303-330 is_object_base_only_class_change, :332-351 empty_parens_class_header_only_change.
  • Parser reuse: legacy_class_header_shape parses through the repo's own parse_module_result (crates/ripr/src/analysis/language/python/source_facts.rs:595-606, budget-bounded by parse_budget::nesting_budget_reason) and reads rustpython_parser::ast::{Expr, Mod, Ranged, Stmt} (no_behavior.rs:8), so the guard shares the module's parse owner instead of introducing a second parser.
  • Effect wiring: classify.rs:254-297 shows the guard order - the no-op/docstring guard (#1279), the comment/whitespace guard (#10706) and the structural def-header guard run first, and the new class-header decision lands inside the annotation-only branch, so the withhold is per changed line, not per file. classify.rs:293 also requires same_indentation(old, line_text).
  • Oracle read: crates/ripr/src/analysis/language/python/tests.rs:3334-3364 (guard matrix appended to annotation_only_detection_is_conservative), :3367-3395 new end-to-end object_base_only_class_header_change_emits_no_probe.
  • Precedent for the oracle shape: the sibling #1289 guard carries a classify-level positive control at tests.rs:3281-3304 (default_value_change_in_def_still_classifies asserts finding.is_some()).
  • Golden drift: I searched the head's crates/ripr/src/analysis/language/python/verdict_corpus_tests.rs for class X(object) and object_base rows and found none, so the withhold cannot move a pinned corpus row. The body's "no verdict-corpus golden changes" claim holds.
  • Governing issue #11888 (open). Its proposed fix - a closed allow-list in no_behavior.rs beside is_annotation_only_def_change, same name and keywords, base list differing only by a sole bare object, everything else keeping today's verdict - is what this head implements. The issue's premise still holds at this base: class X(object): -> class X: is a Python 3 no-op, and this is the same shape as the existing #1289/#10706 withholds.

Blocking:
None. I found no defect in the current head's change, and the guard fails closed on every input I could construct.

Non-blocking:

  1. The end-to-end oracle has no paired positive control. tests.rs:3367-3395 asserts only finding.is_none() for the class Box(object): -> class Box: case. Nothing asserts that class Box(Base): -> class Box: (or class Box(object, Mixin): -> class Box:) still produces a finding through classify_change_with_old. The guard-level negatives at tests.rs:3344-3364 prove the helper is closed, but not that the classify path still classifies a non-object class header. I also searched the head's tests.rs for any other case where a class header is the changed line and found none, so nothing else in the file pins that a class-header change classifies at all - which also means I cannot rule out, without executing, that classify_change_with_old already returns None for a class-header line for an unrelated reason and that the new end-to-end assertion is therefore weaker than the claimed red witness. One finding.is_some() case for a non-object base would close both gaps.
  2. Two narrow false-negative holes remain in the "closed" allow-list, both in the missed-advisory direction:
    a. legacy_class_header_shape accepts any bare object name (no_behavior.rs:291-299) without checking that object is the builtin. If a module rebinds object (e.g. object = int), class Box(object): -> class Box: changes the base class, and the guard withholds the probe.
    b. legacy_class_header_shape works on the trimmed line text alone, with no multi-line-string context. A changed line inside a multi-line string that literally reads class Foo(object): -> class Foo: is withheld, although the string's value does change. The sibling comment/whitespace guard already declines to fire inside a multi-line string (classify.rs:270-272, no_behavior.new_line_in_multiline_string); the new guard does not consult that flag.
  3. docs/CHANGELOG_POLICY.md asks for "one fragment file under changelog.d/ per PR" and lists user-visible output changes among the include-criteria. This PR changes user-visible Python output (a false exposed finding disappears) and adds no fragment, while sibling #11936 in the same wave adds one. cargo xtask check-changelog-fragments validates fragments that exist and does not require one to exist (xtask/src/policy/changelog_fragments.rs:40-89), so this is a convention gap rather than a gate failure - but the written policy and the sibling precedent point the same way.
  4. Guard cost: is_object_base_only_class_change calls legacy_class_header_shape up to four times per changed line (no_behavior.rs:303-351), each re-parsing a synthetic module through parse_module_result. Only lines starting with "class " pay this and the parse is budget-bounded, so the cost is bounded, but the empty-parens case could reuse the two shapes the main path already computed.
  5. Naming: is_annotation_only_def_change now also decides class-header edits (no_behavior.rs:360-366), so its name no longer describes what it decides at its production consumer classify.rs:294. The doc comment was updated; the identifier was not. Renaming it, or splitting the class-header decision into a sibling called from classify.rs, would keep the semantic owner legible.
  6. Earlier review 5725181984 was bound to this same head. Its factual claims hold: the allow-list is wired at the top of is_annotation_only_def_change, classify.rs:294 is unchanged, and there is no verdict-corpus drift. Its disposition REVIEW_READY does not hold: hosted required proof on this head was not terminal when I reviewed, and REVIEW_READY requires a green hosted head. Its own body also says "hosted CI pending on this head", which contradicts REVIEW_READY.

Hosted evidence for this head:

  • Ripr Rust Small on GitHub Hosted / Rust gates - in_progress at review time (check 124680308402, started 22:46:20Z). No Rust tests shard job existed yet for this SHA, so the required Rust test lane had not started.
  • Green on this head: Admit PR Candidate, build and inspect Linux x64 wheel, clean pip install and useful Python journey, clean uv install and useful Python journey, Detect Docs-Only Surface, Rust-only feature lane, dependency-review, cargo-deny, paste-ubuntu-latest, paste-windows-latest, paste-macos-latest, Graphite / mergeability_check, GitGuardian Security Checks, workflow policy and wheel applicability, Route Ripr Rust Small, ub-review. CodeRabbit neutral. msrv, source-identity, vscode, rust-coverage, rust-tests-junit, future-clippy, windows-advisory, macos-advisory, Perl and release proof, Ripr Docs Gate are skipped - unobserved, not green.
  • Base fa621a32eaf4c3dc6c17119021ea943641696aef has no comparable Rust check-run of its own, so no base-green comparison was available; no red appeared on this head, so no inherited-red attribution (including the known main-red python guard_activation test) applies here.

Not run:

  • No Rust toolchain on this host - rustc, cargo and rustup are absent from PATH - so I could not run cargo test -p ripr object_base, cargo test -p ripr annotation_only_detection_is_conservative, cargo xtask precommit, cargo xtask check-changelog-fragments, cargo xtask check-traceability or cargo xtask goldens check. Every gate result in the PR body is a producer claim I could not reproduce.
  • I could not execute the new tests, so the claim that object_base_only_class_header_change_emits_no_probe is a red witness before the guard existed is unverified here; I checked the code path statically instead.
  • I did not run the combined-tree (current main merged into this head) compile check that docs/LEARNINGS.md 2026-10-08 (#7150) asks for before merge: no toolchain, and this pass is read-only.
  • The change was read from REST pulls/11932/files; gh pr diff under-reports merge-commit PRs and GraphQL PullRequestChangedFile carries no patch field.

Reviewed by an independent Mavis review agent on behalf of the maintainer; bound to head e71003b7f2e55f47e3e1a99de79d1c4c1e630b9a. Not an approval.

@EffortlessSteven
EffortlessSteven merged commit 62a2c41 into main Oct 31, 2026
59 of 60 checks passed
@EffortlessSteven
EffortlessSteven deleted the cursor/python-object-base-guard-11888-ad4a branch October 31, 2026 23:17
EffortlessSteven pushed a commit that referenced this pull request Nov 1, 2026
…11888)

Drop the duplicate is_object_base_only_class_change (main's #11932 owns it).
Keep only what main lacks: the annotation-only header guard now also requires
!new_line_in_multiline_string, and a changed PEP 695 type parameter keeps its
probe. Pinned tests cover keywords, nesting, one-line and multi-line headers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018waZYroArgiNqfVvpNJa8b
EffortlessSteven added a commit that referenced this pull request Nov 1, 2026
… 695 (#11888) (#11933)

* fix(python): a sole `object` base edit to a class header earns no probe (#11888)

`class X(object):` and `class X:` are the same class in Python 3, so a
header edit that only adds or drops that one base has no behavior delta.
It previously read `exposed` from any strong test reaching the class
(toolz a39cd67854: curry, juxt, excepts). The new guard is a closed
allow-list in no_behavior.rs: same name, identical other bases and
keywords, parseable single-line header; everything else keeps its verdict.

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

* fix(python): object-base class guard honors multiline strings, keywords and PEP 695 (#11888)

Review repairs: the guard now carries the same !new_line_in_multiline_string
precondition as the comment/whitespace guard; dropping `object` beside any
keyword keeps its probe (a metaclass can observe the bases); PEP 695 type
parameters must match exactly. Adds pinned tests for the multiline-string flag,
indentation mismatch, nested class, one-line and multi-line headers.

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

* fix(python): harden the object-base class guard as a delta over main (#11888)

Drop the duplicate is_object_base_only_class_change (main's #11932 owns it).
Keep only what main lacks: the annotation-only header guard now also requires
!new_line_in_multiline_string, and a changed PEP 695 type parameter keeps its
probe. Pinned tests cover keywords, nesting, one-line and multi-line headers.

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

* fix(changelog): keep the 11888 fragment free of link-shaped text

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
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: a no-op class-header edit (class X(object): to class X:) reads exposed (false exposed)

2 participants