jedi
jedi copied to clipboard
How to detect undefined references (NameError, ecc.)?
Hi, this is probably a stupid question, but I noticed that Jedi does not report an error (at least in VSCode) when accessing a non-existing function/property of an object or of a module. Is it outside the scope of the project or is it something the user is supposed to detect themselves using the information exposed by the API?
You should probably use mypy for that. I'm currently working on a tool that does that (Rewrite of Jedi & Mypy in Rust), but this will take quite a long time, still (it's been almost 3 years already).
But can't Jedi exploit the same info used by autocomplete to do that? I mean, if I have this module:
foo = 1
def fun1():
pass
def fun2():
pass
script.autocomplete()
will show me this if I import it:
so It should be just a matter of checking if the accessed function/attribute actually exists in that list, right? I tried to do it manually but looks like there isn't an API to get the list of the symbols exposed by a module
This is a bit of a complex topic. Jedi could do this partially, but it would be very slow. However the partial part is also important. Jedi was never designed to do that, because type checkers typically have a different architecture, than what I set out to do with Jedi. It's why I'm rewriting it.
Jedi also sometimes uses heuristics, which is something type checkers usually don't do. Also imagine how long a completion typically takes and then multiply that by potentially 2000 lookups and you'll quickly see that it's very complicated. :)