[Bug]: Python mod.Box[T] annotation gets a false generic_arg edge that replaces the parameter_type one ('is' on tree-sitter nodes)
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start in graphify/extractors/engine.py at _python_collect_type_refs, specifically the subscript branch described in the issue. Reproduce the case with mod.MyBox[Foo] and compare the collected references with the expected output. Done means the extra MyBox generic_arg reference is gone while the type and Foo generic_arg references remain.
Written by the indexing model from the issue text.
Description
Pre-flight checks
- I have checked the Troubleshooting section in the README
What happened?
A dotted generic annotation like def f(x: mod.MyBox[Foo]) gets a false references edge to MyBox with context: generic_arg. graph.json keeps one edge per node pair, so this false edge replaces the correct parameter_type / return_type edge.
The cause is in _python_collect_type_refs (graphify/extractors/engine.py), subscript branch:
for c in node.children:
if c is value or not c.is_named:
py-tree-sitter returns a new Node object on every access, so c is value is never true (== works). The subscript's value is walked twice: once as the type, then again as one of its own generic arguments.
A plain MyBox[Foo] parses as generic_type and is not affected; only the dotted form is.
Steps to reproduce
# repro.py
import tree_sitter_python as tsp
from tree_sitter import Language, Parser
from graphify.extractors.engine import _python_collect_type_refs
src = b"def f(x: mod.MyBox[Foo]): ...\n"
tree = Parser(Language(tsp.language())).parse(src)
ann = tree.root_node.children[0].child_by_field_name("parameters").named_children[0].child_by_field_name("type")
out = []
_python_collect_type_refs(ann.named_children[0], src, False, out)
print(out)
Error output or graph output
got: [('MyBox', 'type'), ('MyBox', 'generic_arg'), ('Foo', 'generic_arg')]
expected: [('MyBox', 'type'), ('Foo', 'generic_arg')]
Edges with the wrong context in real graphs: click 39, flask 21, requests 6 (django has almost no annotations, so 0).
Graphify version
0.9.105 (v8 at 5eedffa8)
Operating System
Windows (also seen on Linux)
Python Version
3.12
Installation Method
uv tool install (recommended)
- Dominant language
- Python
- Stars
- 124k
- Forks
- 11.9k
- Avg merge
- 2h 35m
- Merged PRs (30d)
- 6
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Graphify-Labs/graphify
-
[Bug]: graphify query prints a different answer on each run (BFS walks a set in hash order)Possibly taken @rohit-jsfreaky claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Graphify-Labs/graphify#5109 · 1 comment ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Graphify-Labs/graphify#5006 · 2 comments ·
Maintainers usually reply within 2 days
-
extract --out <dir>: semantic cache never saved, docs missing from manifest (relative source_file resolved against --out)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Graphify-Labs/graphify#4831 · 3 comments ·
Maintainers usually reply within 2 days
-
hooks: last-resort `python3` probe launches the Microsoft Store redirector on Windows (visible console flash, exit 9009)Possibly taken @Deepjyoti-Sarmah claimed this 21 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Graphify-Labs/graphify#4563 · 2 comments ·
Maintainers usually reply within 2 days
-
GRAPHIFY_DISABLE_THINKING is ignored by the claude backend, so thinking eats max_tokens and extraction truncatesPossibly taken @bercedev claimed this 21 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
Graphify-Labs/graphify#4546 · 1 comment ·
Maintainers usually reply within 2 days
All issues in Graphify-Labs/graphify
Similar issues
-
`destroy` sans terminal répond « Aborted. » au lieu de réclamer `--yes` comme `clean` et `reset`Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
stephrobert/dsoxlab#354 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
jasonacox/pypowerwall#472 ·
Maintainers usually reply within 1 day
-
[Bug]: DoubleMLRDDData accepts a score_col that is no data column (as in its docstring example); the running variable then becomes a covariate and RDFlex failsPossibly taken @vrjdev claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
DoubleML/doubleml-for-py#455 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
assafelovic/gpt-researcher#2277 ·
Maintainers usually reply within 10 days
-
Install page: spectarf's CUDA engine fails with PyTorch for CUDA 13.0 (nvvmError: ERROR_INVALID_IR)Possibly taken @lukepolson claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
PyTomography/PyTomography#435 ·
Maintainers usually reply within 1 day