-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python module resolution not working via tree-sitter-stack-graphs-python cli #430
Comments
I just tried in javascript with a similar project structure, and it works just fine:
// index.js
import { foo } from "./module"
const baz = foo // module.js
export const foo = "bar" REPO="/Users/nohehf/tmp/js"
tree-sitter-stack-graphs-javascript clean --all
tree-sitter-stack-graphs-javascript index $REPO
tree-sitter-stack-graphs-javascript status $REPO
/Users/nohehf/tmp/js/index.js: indexed
/Users/nohehf/tmp/js/module.js: indexed tree-sitter-stack-graphs-javascript query definition "index.js:3:13"
/Users/nohehf/tmp/js/index.js:3:13: found 2 definitions for 1 references
queried reference
/Users/nohehf/tmp/js/index.js:3:13:
3 | const baz = foo
| ^^^
has 2 definitions
/Users/nohehf/tmp/js/index.js:1:10:
1 | import { foo } from "./module"
| ^^^
/Users/nohehf/tmp/js/module.js:1:14:
1 | export const foo = "bar"
| ^^^
|
From what I see, the import is modeled as a push (with a downward arrow) of I wonder what happens if you run the index command in the directory itself? I think there's some logic missing that takes the source root into account when computing the module names. |
Hello @hendrikvanantwerpen, do you have any idea on this one ? |
@nohehf I don't immediately know what might be going on here. One quick experiment you could do is to replicate your test case in TypeScript, and see how the graphs differ. This will give us a starting point for what to look at. |
This is the JavaScript reproduction: #430 (comment) Here is an archive with the source code and the We can see that in the visualization we do have the right push & pop on the full path. |
Hello again,
I've been testing
tree-sitter-stack-graphs-python
via the cli, and while I have great results on a single file, I was not able to obtain concluent output on multiple files with modules.Here is a minimal reproduction of my issue:
Given the following directory structure (working dir being:
/Users/nohehf/tmp/py
):. ├── main.py └── module.py
With:
If I run:
I get:
Now if I query
main.py
on thefoo
reference (main.py:3:14), it does not find the definition inmodule.py
:However, trying to reproduce the behaviour in a test (
test.py
) I get no issues:tree-sitter-stack-graphs-python test test.py test.py: success
Am I missing something with the cli ? Are tests really behaving like those are separate files ?
I'm sure this is supposed to work and I have trouble understanding what's going on in the graph visualization:
Thank you
The text was updated successfully, but these errors were encountered: