[Bug]: Python files can disappear from the graph when a class is used before it's defined
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start by running graphify update . on the two-file reproduction in the issue and inspect graphify-out/graph.json to trace how the class reference before its definition affects file and class nodes. Find the Python parsing and graph construction entry points that handle those references; the issue does not name specific source files or tests. Done means widget.py remains in the graph, references resolve to its Widget class, and the missing call from Helper.make appears.
索引モデルが issue の本文から書いたものです。
説明
What's happening
In some Python projects, whole files go missing from the graph, and the classes inside them get tangled up. There's no error, so it's easy to miss.
I noticed it on rich: when I ran graphify update rich/rich, two of its main files, markdown.py and syntax.py, weren't in the graph at all.
When it happens:
- the file itself disappears from the graph
- the class with the same name as the file ends up "containing" itself and every other class in the file
- other files that import it look like they import the class instead of the file
- some calls made from inside that file are quietly left out
When it happens
All three of these at once:
- The file is directly in the folder you point graphify at, not in a subfolder
- It has a class with the same name as the file, like
Widgetinwidget.py - Something earlier in that file mentions the class before it's defined, like a type hint
w: Widget
Naming a file after its main class is pretty common, like console.py with Console, so this shows up in real projects.
How to see it for yourself
Make a folder with these two files and run graphify update .:
widget.py
from __future__ import annotations
class Helper:
def make(self, w: Widget) -> None:
w.draw()
class Widget:
def draw(self):
return 1
app.py
from widget import Widget
def use(w: Widget):
w.draw()
Then look at graphify-out/graph.json:
- there's no
widget.pynode Widget"contains" itself andHelperapp.pyimportsWidgetthe class instead ofwidget.pythe file- the call from
Helper.maketoWidget.drawis missing, while the same call fromapp.pyis there
What should happen
widget.py should be in the graph like any other file, and the Widget it mentions should just point to the class defined lower down in the same file.
How much it matters
I checked graphify's call links against Jedi on rich. On 0.9.85, with this fixed, graphify finds 54 more correct calls, going from 64.6% to 68.6%, with no wrong links added and none lost. Both missing files come back too.
Version: graphify 0.9.85 · macOS 26.4 · Python 3.14
- 主要言語
- Python
- スター
- 124k
- フォーク
- 11.9k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Graphify-Labs/graphify のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
Graphify-Labs/graphify#3763 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Graphify-Labs/graphify#3611 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Nix supportオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Graphify-Labs/graphify#3193 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
Graphify-Labs/graphify#2871 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Graphify-Labs/graphify#2865 ·
メンテナーはふだん 1 日以内に返信
Graphify-Labs/graphify の issue をすべて見る
似ている issue
-
bug difficulty:2 good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
MakazhanAlpamys/Soup#1865 ·
メンテナーはふだん 1 日以内に返信
-
area: agents area: docs good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
openapi/gknowledge#23 ·
-
useless-suppression reported for deprecated-* messages that should be exempt対応中かも @adityasinha-ghub が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
pylint-dev/pylint#11656 ·
メンテナーはふだん 1 日以内に返信
-
area:provisioning effort:S priority:P2 provider:local-libvirt risk:daytime-only status:in-progress type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
randomparity/kdive#3203 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
get() for StrEnum対応中かも @FeJo5952 が今日担当しました。 オープンgood first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
collective/icalendar#1921 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信