[Bug]: Python @property reads produce no edge, so callers_of and find_dead_code miss every consumer

Author: peyckCreated Sep 19, 2026Updated Sep 19, 2026
Labelsbug

code-review-graph version

2.3.9

Operating system

Windows

Python version

3.11

AI platform

claude-code

Output of code-review-graph status

bash
Nodes: 13
Edges: 18
Files: 2
Languages: python
Last updated: 2026-09-19T14:57:48
Built on branch: master
Built at commit: d0e9de9a5ffd

Steps to reproduce

  1. Create a repo with two files.

engine.py:

class Engine:
    def run(self) -> str:
        return "ok"


class Orchestrator:
    def __init__(self) -> None:
        self._engine = Engine()

    @property
    def secondary_engine(self) -> Engine:
        """Read as an attribute, never called with ()."""
        return self._engine

consumer.py:

from engine import Orchestrator


class Holder:
    def __init__(self) -> None:
        self.orch = Orchestrator()

    def via_self(self) -> str:
        """Receiver is self -> resolves."""
        return self.helper()

    def helper(self) -> str:
        return "x"

    def reads_property(self) -> str:
        """Receiver is an attribute chain -> property read, no edge at all."""
        engine = self.orch.secondary_engine
        return engine.run()


def entrypoint() -> str:
    return Holder().reads_property()
  1. git init && git add -A && git commit -m init
  2. code-review-graph build
  3. Query callers of the property, e.g. via the MCP tool: query_graph(pattern="callers_of", target="/engine.py::Orchestrator.secondary_engine")

Tested on 2.3.9 (also reproduces on 2.3.2), Python 3.11, Linux.

Expected vs actual behavior

Expected: callers_of("engine.py::Orchestrator.secondary_engine") reports Holder.reads_property, which reads the property on line 17.

Actual: it reports 0 callers. Reading a @property never creates an edge, so the property node exists with nothing pointing at it.

All CALLS edges produced by the build above:

consumer.py::Holder.init -> engine.py::Orchestrator (line 6) consumer.py::Holder.reads_property -> run (line 18) consumer.py::Holder.via_self -> consumer.py::Holder.helper (line 10) consumer.py::entrypoint -> consumer.py::Holder (line 22) consumer.py::entrypoint -> consumer.py::Holder.reads_property (line 22) engine.py::Orchestrator.init -> engine.py::Engine (line 8)

Two defects are visible:

  1. The property read on line 17 produces no edge at all. Not an unresolved one, none.
  2. The call on line 18 has the bare target "run" instead of engine.py::Engine.run, because the receiver is a local whose type is not inferred.

callers_of reflects both:

consumer.py::Holder.helper via self.helper() -> 1 (correct) engine.py::Engine.run via engine.run() -> 0 (bare target) engine.py::Orchestrator.secondary_engine via self.orch.secondary_engine -> 0 (no edge)

Additional context

Cause: in parser.py,

_CALL_TYPES: dict[str, list[str]] = {
    "python": ["call"],
    ...
}

Only tree-sitter call nodes become CALLS edges. A property read is an attribute node, so it is never considered. REFERENCES does not cover it either: it is emitted for function-as-value patterns (callbacks, dict values, array elements), not attribute reads.

Downstream impact: find_dead_code decides on CALLS, TESTED_BY, IMPORTS_FROM, REFERENCES and INHERITS. None capture a property read, so a @property that is the public accessor for a subsystem looks dead. On a real Python codebase (~250 files, ~4600 nodes) I ran refactor_tool(mode="dead_code") over one module and got 5 reported dead symbols, all 5 false positives: four were @property accessors with 1 to 5 live consumers each, the fifth a nested function passed as a value. Those four properties are that module's main public surface. Since CLAUDE.md guidance generated by this tool points agents at refactor_tool for finding dead code, an agent acting on that output would propose deleting live code.

A fix that does NOT work: adding "attribute" to _CALL_TYPES["python"]. I tried it. Edges on the real codebase went from 40,129 to 79,261, nearly double, and the property reads are still not found, because for an attribute node _get_callee_name takes children[0], which is the object, not the member; with a chained receiver that child is itself an attribute node. It also creates name-collision artefacts where a local happens to share a name with a property. A real fix needs the receiver's type resolved.

Relation to #984: that issue is the opposite failure mode, targets invented when resolution is uncertain. This is targets missing when resolution is uncertain. The fix suggested there (keep plain names, rewrite only when the node is confirmed) would not help case 1, where no edge is produced at all.

Source: tirth8205/code-review-graph