[Bug]: Python files can disappear from the graph when a class is used before it's defined
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #4343 của @Mpasha17 — đã đóng, không merge
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 124k
- Fork
- 11.9k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Graphify-Labs/graphify
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Graphify-Labs/graphify#3763 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Graphify-Labs/graphify#3611 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Nix supportĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Graphify-Labs/graphify#3193 · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
Graphify-Labs/graphify#2871 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Graphify-Labs/graphify#2865 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Graphify-Labs/graphify
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Deltares/imod-python#1940 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
effort: low prio: low ready
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
digitalfabrik/integreat-cms#4621 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
ioos/compliance-checker#1375 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
netbox status: backlog topic: testing type: housekeeping
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
netbox-community/netbox#23395 ·
Maintainer thường phản hồi trong vòng 1 ngày