Repository navigation
fix(python): withhold probe for legacy object-only class header edits (#11888) - #11932
Conversation
…#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>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
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. View limit details
|
EffortlessSteven
left a comment
There was a problem hiding this comment.
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.
|
Merge-ready at head |
EffortlessSteven
left a comment
There was a problem hiding this comment.
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, basefa621a32eaf4c3dc6c17119021ea943641696aef, non-draft, labelmerge-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 RESTpulls/11932/files. - Semantic owner of the changed behavior:
crates/ripr/src/analysis/language/python/no_behavior.rs:363-366is_annotation_only_def_change, the single production decision point. Its only production consumer iscrates/ripr/src/analysis/language/python/classify.rs:292-297, where the guard returnsNonefor that changed line.classify.rsis 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 bytests.rs. - New guard:
no_behavior.rs:266-269LegacyClassBaseShape,:271-301legacy_class_header_shape,:303-330is_object_base_only_class_change,:332-351empty_parens_class_header_only_change. - Parser reuse:
legacy_class_header_shapeparses through the repo's ownparse_module_result(crates/ripr/src/analysis/language/python/source_facts.rs:595-606, budget-bounded byparse_budget::nesting_budget_reason) and readsrustpython_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-297shows 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:293also requiressame_indentation(old, line_text). - Oracle read:
crates/ripr/src/analysis/language/python/tests.rs:3334-3364(guard matrix appended toannotation_only_detection_is_conservative),:3367-3395new end-to-endobject_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_classifiesassertsfinding.is_some()). - Golden drift: I searched the head's
crates/ripr/src/analysis/language/python/verdict_corpus_tests.rsforclass X(object)andobject_baserows 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.rsbesideis_annotation_only_def_change, same name and keywords, base list differing only by a sole bareobject, 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:
- The end-to-end oracle has no paired positive control.
tests.rs:3367-3395asserts onlyfinding.is_none()for theclass Box(object):->class Box:case. Nothing asserts thatclass Box(Base):->class Box:(orclass Box(object, Mixin):->class Box:) still produces a finding throughclassify_change_with_old. The guard-level negatives attests.rs:3344-3364prove the helper is closed, but not that the classify path still classifies a non-objectclass header. I also searched the head'stests.rsfor 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, thatclassify_change_with_oldalready returnsNonefor a class-header line for an unrelated reason and that the new end-to-end assertion is therefore weaker than the claimed red witness. Onefinding.is_some()case for a non-objectbase would close both gaps. - Two narrow false-negative holes remain in the "closed" allow-list, both in the missed-advisory direction:
a.legacy_class_header_shapeaccepts any bareobjectname (no_behavior.rs:291-299) without checking thatobjectis the builtin. If a module rebindsobject(e.g.object = int),class Box(object):->class Box:changes the base class, and the guard withholds the probe.
b.legacy_class_header_shapeworks on the trimmed line text alone, with no multi-line-string context. A changed line inside a multi-line string that literally readsclass 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. docs/CHANGELOG_POLICY.mdasks for "one fragment file underchangelog.d/per PR" and lists user-visible output changes among the include-criteria. This PR changes user-visible Python output (a falseexposedfinding disappears) and adds no fragment, while sibling #11936 in the same wave adds one.cargo xtask check-changelog-fragmentsvalidates 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.- Guard cost:
is_object_base_only_class_changecallslegacy_class_header_shapeup to four times per changed line (no_behavior.rs:303-351), each re-parsing a synthetic module throughparse_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. - Naming:
is_annotation_only_def_changenow also decides class-header edits (no_behavior.rs:360-366), so its name no longer describes what it decides at its production consumerclassify.rs:294. The doc comment was updated; the identifier was not. Renaming it, or splitting the class-header decision into a sibling called fromclassify.rs, would keep the semantic owner legible. - 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:294is unchanged, and there is no verdict-corpus drift. Its dispositionREVIEW_READYdoes not hold: hosted required proof on this head was not terminal when I reviewed, andREVIEW_READYrequires a green hosted head. Its own body also says "hosted CI pending on this head", which contradictsREVIEW_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). NoRust tests shardjob 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.CodeRabbitneutral.msrv,source-identity,vscode,rust-coverage,rust-tests-junit,future-clippy,windows-advisory,macos-advisory,Perl and release proof,Ripr Docs Gateareskipped- unobserved, not green. - Base
fa621a32eaf4c3dc6c17119021ea943641696aefhas 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 pythonguard_activationtest) applies here.
Not run:
- No Rust toolchain on this host -
rustc,cargoandrustupare absent from PATH - so I could not runcargo 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-traceabilityorcargo 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_probeis 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.md2026-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 diffunder-reports merge-commit PRs and GraphQLPullRequestChangedFilecarries nopatchfield.
Reviewed by an independent Mavis review agent on behalf of the maintainer; bound to head e71003b7f2e55f47e3e1a99de79d1c4c1e630b9a. Not an approval.
…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
… 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>
Summary
Pyupgrade-style edits that only remove or add the legacy bare
objectbase (or empty()before:) on a single-line class header are behavior-preserving. Route them through the existing annotation-only withhold inno_behavior.rssoclass Box(object):→class Box:no longer readsexposed.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
objectbase or empty()emits no probe, matching annotation-onlydefwithhold behavior.Closes #11888
Scope Classification
Production delta: closed allow-list guard
is_object_base_only_class_changeconsulted fromis_annotation_only_def_change;classify.rsunchanged.Evidence/support delta: unit guard cases and Box end-to-end test in
python/tests.rs.Proof
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.