[Bug]: Python files can disappear from the graph when a class is used before it's defined
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
- #4343 de @Mpasha17 — cerrado sin fusionar
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 124k
- Forks
- 11.9k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Graphify-Labs/graphify
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Graphify-Labs/graphify#3763 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Graphify-Labs/graphify#3611 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Nix supportAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Graphify-Labs/graphify#3193 · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
Graphify-Labs/graphify#2871 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Graphify-Labs/graphify#2865 ·
Los mantenedores suelen responder en 1 día
Todos los issues de Graphify-Labs/graphify
Issues similares
-
Workflow.schedule stops when a cron deadline passes before sleepPosiblemente ocupada @HuaTNA la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
[Bug] HiveDialect shares its colspecs dict with SQLAlchemy's DefaultDialect (python/pyhive)Posiblemente ocupada @rusackas la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
apache/kyuubi#7786 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
Los mantenedores suelen responder en 1 día
-
[20.0] hr_work_entry: Duration column of Export Time Entries is truncated to whole hoursPosiblemente ocupada @odooaktiv la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
fix formatting of the sample database page of the docsPosiblemente ocupada @Aaqibhafeezkhan la tomó hoy. Abiertodocumentation good first issue help wanted
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
chaoss/CollectOSS#544 · 1 comentario ·
Los mantenedores suelen responder en 1 día