Skip to content

named_attribute: exempt probes that restate no declaration of the scan's - #477

Merged
trissim merged 1 commit into
mainfrom
s-nra/named-attribute-precision-r
Nov 18, 2026
Merged

trissim merged 1 commit into
mainfrom
s-nra/named-attribute-precision-r

Conversation

@trissim

@trissim trissim commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Numbers (measured on the mains before #475): named_attribute 73 → 51 across the three benches (agent-comms 5 → 1, toad 28 → 27, textual 40 → 23).

What changed

  • Each probe site carries the first AttributeProbeExemption it matches. named_attribute skips exempt sites, and so does absent_attribute_probe (Report attribute probes that never succeed #475).
  • The seven exemption checks:
    1. stdlib attributes of callables (__qualname__, __name__, a partial's func/args/keywords) on a receiver the same function checks with callable/inspect;
    2. a local bound only by a stdlib call, iter or open;
    3. a dunder protocol name;
    4. a value from import_module;
    5. an init or misuse guard (hasattr on self inside __repr__/__rich_repr__/__str__, or a test whose body only raises or warns);
    6. a setattr that is a lambda's whole body;
    7. a probe where the same function's isinstance on the receiver said no (a later or operand, the else branch, or after an if isinstance(...) that returns, raises, breaks or continues).
  • Kept as findings on purpose:
    • decorator markers (_height_dependency), since every reader restates the decorator's fact;
    • a probe after an isinstance that said yes (textual/_animator.py:442), which is a declarable contract.

Evidence

  • One fixture per exemption shape; each is reported on main.
  • Near-misses stay named_attribute.
  • Targeted run, 252 passed: test_restated_fact_detectors, test_repository_architecture, test_class_mro, test_declared_receivers, test_type_only_readers.
  • -k test_repository_: 72 passed.

Generated by Claude Code

named_attribute now skips seven shapes where no declaration of ours can
hold the probe: stdlib callable metadata (__qualname__, __name__, an
inspected partial's func), a standard-library object bound in the
function, a dunder protocol, a module from import_module, an
initialization or misuse guard, a setattr that is a lambda's body, and
the open fallback of an isinstance decoder (only where the isinstance
said no). Markers our own decorators set on functions stay findings.
An exempt probe is never absent_attribute_probe's either; both detectors
keep the one shared context builder.

Bench counts at origin/main before #475: agent-comms 5 -> 1, toad
28 -> 27, textual 40 -> 23.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016gZLduhisRHdamZ5LNK72Z
@trissim
trissim merged commit 641fdbd into main Nov 18, 2026
0 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants