Skip to content

Python: third-party decorators (e.g. @pytest.fixture) not in _PYTHON_DECORATOR_NOISE create spurious god-node edges when a corpus has a same-named local function #2732

Open

Description

@JrWater

Summary

_PYTHON_DECORATOR_NOISE (extractors/engine.py:74) excludes common stdlib decorators (property, dataclass, staticmethod, etc.) from decorator-reference-edge generation, with this rationale in the comment above it:

Builtin/stdlib decorators (@Property, @DataClass, @functools.wraps, …) are ambient vocabulary, not corpus symbols: emitting decorator edges for them fabricates sourceless stub nodes on nearly every class-heavy file, and the unique-function rewire can collapse them onto an unrelated local definition (a corpus defining its own def wraps(...) gets a false decorator edge).

pytest.fixture is not in that noise list, and it hits exactly the failure mode the comment describes — just from a third-party decorator instead of a stdlib one.

Repro

Corpus: a Python test suite using @pytest.fixture extensively across ~250 test files, one of which happens to define a local, non-decorator function literally named fixture() (workspace/tests/test_eodhd_readiness_check.py:22, unrelated to pytest — just a locally-named helper).

Result: that one fixture() node ends up with 44 edges (the #1 "God Node" in the report) — 42 of them relation: references, context: decorator, confidence: EXTRACTED — pointing to ~30 completely unrelated local pytest fixtures in other files (env(), db(), ob(), cb(), repo(), archive(), qt(), ns(), mod(), gs(), shape(), close(), keepalive(), caldb(), etc.). None of these functions call, import, or otherwise relate to each other — they're independent per-file pytest fixtures. The "unique-function rewire" for the @pytest.fixture decorator name is binding to that one same-named local function instead of correctly recognizing pytest.fixture as an external symbol.

Net effect: a completely spurious "god node" / architectural hub shows up in GRAPH_REPORT.md's God Nodes and (via BFS from it) Suggested Questions sections, pointing the user at a non-existent coupling.

Suggested fix

Add common third-party test-framework decorators to _PYTHON_DECORATOR_NOISE (or, more robustly, only emit a decorator reference edge when the decorator name resolves to a definition actually imported in that file — i.e. respect import scope instead of doing a same-bare-name global lookup). At minimum: fixture, mark, parametrize, pytest.fixture (pytest), plus maybe click.command, app.route / app.get / app.post (Flask/FastAPI) as other common third-party decorators likely to collide with locally-defined function names in real corpora.

Environment

  • graphifyy 0.9.41
  • Corpus: ~700-file mixed Python/docs personal project, code-only AST pass (no LLM involved in this specific extraction — confidence: EXTRACTED, purely deterministic)

Activity

  1. hementhu commented on Oct 16, 2026

    @hementhu
    Contributor

    @aayush598, is #2739 still on your list? It was closed right after the review round and didn't land. If not, I'd like to take #2732 with a general version: keep the decorator's module prefix when it's an imported module (import pytest → @pytest.fixture) and only let the corpus rewire bind a prefixed stub to a top-level def in that module's file, so @myhelpers.retry still links and third-party decorators can't. That's the imported-receiver case #2356 deliberately leaves on bare names. @Rishet11, happy to build on #2356 rather than conflict with it.

  2. aayush598 commented on Oct 21, 2026

    @aayush598

    Hi @hementhu, I'm happy for you to take this issue forward.

    3. @aayush598, is #2739 still on your list? It was closed right after the review round and didn't land. If not, I'd like to take #2732 with a general version: keep the decorator's module prefix when it's an imported module (import pytest → @pytest.fixture) and only let the corpus rewire bind a prefixed stub to a top-level def in that module's file, so @myhelpers.retry still links and third-party decorators can't. That's the imported-receiver case #2356 deliberately leaves on bare names. @Rishet11, happy to build on #2356 rather than conflict with it.

  3. hementhu commented on Oct 21, 2026

    @hementhu
    Contributor

    Thanks @aayush598! PR is up: #4622. It keeps the decorator's import origin (import pytest, import pytest as pt, from pytest import fixture) on the edge and only lets the rewire bind it to a definition in that module's own file, so @pytest.fixture stays off a local def fixture() while @myhelpers.retry still links. On a 13-file repro the local fixture() drops out of god_nodes() (it was #1 at degree 25).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions