Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Python constructor calls do not reach the initializer they run

オープン
#4,209 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
devtools

調査の方向性

Start with the Python call-graph construction and change-impact traversal, then inspect PR #4208, which describes the proposed constructor-entry edge and its scope. Reproduce the supplied fixture with graphify update and graphify affected; compare the graph before and after, including incremental output against a clean rebuild. Done means constructor calls reach the inferred initializer and callers while preserving all existing nodes and edges and respecting the documented static-analysis limitations.

索引モデルが issue の本文から書いたものです。

説明

Python constructor calls stop at the class node, hiding the initializer's dependencies from change-impact traversal.

Reproduction on current v8

Verified on v0.9.80, commit 6478eb7, with Python 3.13 on Linux. Build these files with graphify update <fixture> --no-cluster:

# pkg/storage.py
def open_db(path):
    return path

class Store:
    def __init__(self, path):
        self.db = open_db(path)

# pkg/cache.py
from pkg.storage import Store

class CachedStore(Store):
    pass

# pkg/service.py
from pkg.cache import CachedStore

def build(path):
    return CachedStore(path)

# tests/test_service.py
from pkg.service import build

def test_build():
    build("test.db")

graphify affected "open_db()" --depth 4 --graph <fixture>/graphify-out/graph.json finds Store.__init__ but misses build() and test_build(). The call graph has build -> CachedStore and Store.__init__ -> open_db, with no call edge joining them.

Constructor fix

PR #4208 adds an inferred constructor-entry edge when a supported source binding and class chain identify the initializer. It preserves the class edge and every other existing node and edge. The fixture then reaches the initializer, build(), its importing test file, and test_build(). Incremental output after editing the caller matches a clean rebuild.

Fresh comparisons against 6478eb7 add 703 constructor edges across seven pinned repositories: Flask 3, requests 3, httpx 56, rich 506, langchain-core 100, yt-dlp 17 and FastAPI 18. All 703 agree with an independent Python ast derivation. All 586 that SCIP can judge agree on the called class, inheritance chain and initializer. Every pre-existing node and edge remains identical.

This is a restricted static subset. Decorators, metaclasses, custom allocation, multiple inheritance, ambiguous bindings, external bases and known mutation patterns add no edge. Cross-module dynamic mutation remains a documented limitation.

Why it matters for test impact

A separate runtime-trace study measured Flask and yt-dlp tests against pinned source revisions. Historical v8 graphs reached only 4 of 3,482 sampled Flask test/function pairs and 20 of 606 yt-dlp pairs. A broader prototype combining receiver typing, constructor entry and pytest fixture dependencies reached 1,699 and 358 respectively. Those are historical prototype results, not the results of this constructor PR or current v0.9.80.

Constructor entry is one missing link in that chain. Since the study, upstream has added self.attr.method() support in #4176 and annotated/constructor-bound local receiver support in #4198. Those changes are already present in the base used to verify this PR. Remaining opportunities include inherited methods, factory return types and pytest fixture dependency edges through the nearest conftest.py chain.

Related: #2041, #2860, #2417, #2586 and #1499.

主要言語
Python
スター
124k
フォーク
11.9k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Graphify-Labs/graphify のほかの issue

Graphify-Labs/graphify の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。