'How to use Jedi's `Project` feature?
So I'm playing around with jedi. I would like jedi to print all references of a specific variable in a directory. To test this out, I wrote something like:
./project/__init__.py:
./project/a.py:
x = 5; x = 7
./src/__main__.py:
from jedi import *
p = Project('./project')
code = """from project.a import x
x"""
s = Script(code, path='./project/b.py', project=p)
res = s.get_references(2, 0)
print(res)
And I'm running it with python3 -m src. However, it doesn't seem to work.
I get
[<Name full_name='project.a.x', description='module x'>, <Name full_name='b.x', description='x'>]
In other words, it seems to think that x is a module, and doesn't find the two uses of x in a.py. Thank you! Any ideas how to accomplish this? Unfortunately, all of the examples only use Scripts without Projects.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
