Skip to content
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

How to detect undefined references (NameError, ecc.)? #1945

Open
debevv opened this issue Jul 6, 2023 · 3 comments
Open

How to detect undefined references (NameError, ecc.)? #1945

debevv opened this issue Jul 6, 2023 · 3 comments
Labels
database-index Needs a database index/Rewrite in Rust (#1059)

Comments

@debevv
Copy link

debevv commented Jul 6, 2023

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?

@davidhalter
Copy link
Owner

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).

@debevv
Copy link
Author

debevv commented Jul 7, 2023

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:
Schermata del 2023-07-07 11-55-59

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

@davidhalter
Copy link
Owner

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. :)

@davidhalter davidhalter added the database-index Needs a database index/Rewrite in Rust (#1059) label Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database-index Needs a database index/Rewrite in Rust (#1059)
Projects
None yet
Development

No branches or pull requests

2 participants