Skip to content

PythonVScode extension doesn`t seem to implement jedi properly - the extension cannot locate the correct symbol definition #171

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

Closed
DonJayamanne opened this issue Nov 14, 2017 · 10 comments
Assignees
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@DonJayamanne
Copy link

From @circlecrystal on August 28, 2017 4:47

  1. In other editors' implementations of jedi can lookup the user defined object, and find the method definition (csv_handle has the writerow() and writerows() methods, and they do show up in some other editor):

other

  1. The vscode python extension implementation of jedi cannot lookup any method which belong to the object of some object of some imported class (label_handle has the writerow() and writerows() methods, but they do not show up in vscode. Instead, vscode show the incorrect methods which don`t actually belong to label_handle object):

vscode

(* The imported class in the above and below showcase is with the Python standard library.)

  1. The vscode python extension implementation of jedi cannot even lookup any user defined MACRO value (it shows the data type instead, which is pretty much useless for us):

vscode 2

As I also investigated this issue a lot, I found it is not the problem of jedi itself. It is vscode python extension does not use the jedi as correctly as it should.

That`s why we have this problem haunting many of us python programmers who are using this extension right now.

Copied from original issue: DonJayamanne/pythonVSCode#1182

@DonJayamanne DonJayamanne added bug and removed m labels Nov 14, 2017
@brettcannon brettcannon added awaiting 1-decision area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug labels Nov 14, 2017
@ghost
Copy link

ghost commented Dec 9, 2017

just wants to check on this - does this mean Jedi integration is finally going to be correct? It appears that Jedi autocomplete is still not working appropriately for me at least.

Also, any consideration to using this? https://github.com/palantir/python-language-server

@brettcannon
Copy link
Member

All we've done is triaged the issue. No specific plans on addressing this issue have been made yet.

@brettcannon
Copy link
Member

@DonJayamanne do you happen to know how we may not be hooking into Jedi fully as suggested by @circlecrystal? I've verified that at least with:

import csv
import io

buf = io.BytesIO()
writer = csv.writer(buf)

doesn't lead to intellisense for writer.

@segevfiner
Copy link

Are you sure this is really an issue with Jedi? Try this:

import jedi
script = jedi.Script(source="""\
import io
import csv

buf = io.BytesIO()
writer = csv.writer(buf)
writer.
""", line=6, column=7)
print(script.completions())

It returns no completions for me. I think Jedi is having trouble since _csv.writer is a builtin function. At least that's for the first mentioned issue, not sure about the rest...

@ghost
Copy link

ghost commented Feb 2, 2018

@segevfiner It doesn't appear any other editor I have tested with Jedi is having this issue. I've used it with Vim & Atom. I have also used the alternative language server which relies on Jedi, with no issues.

Its seems that a few updates ago coding in Python completely broke in vscode. I haven't been able to use it since.

@segevfiner
Copy link

segevfiner commented Feb 2, 2018 via email

@segevfiner
Copy link

segevfiner commented Feb 3, 2018

For the third issue. Showing the values of stuff is done, in Atom at least, by this bit of code:
https://github.com/Microsoft/vscode-python/blob/fafd0f8888b8d6a9a995b8da4495c8a83d3f9a9e/pythonFiles/completion.py#L60-L70
Called from here:
https://github.com/Microsoft/vscode-python/blob/fafd0f8888b8d6a9a995b8da4495c8a83d3f9a9e/pythonFiles/completion.py#L220

It shows it on the right hand side of a completion suggestion. VS Code is probably not using this property. Only showing the doc string for the type of the completion which is what we are seeing (I think it might even be getting the doc string by itself rather than relying on Jedi).

P.S. The code throws a bunch of lint warnings from a linter like flake8, and in particular ARGUMENT_RE is not defined for this bit of code:
https://github.com/Microsoft/vscode-python/blob/fafd0f8888b8d6a9a995b8da4495c8a83d3f9a9e/pythonFiles/completion.py#L254-L255
Though it's probably currently unused by this extension.

@DonJayamanne DonJayamanne added this to the February 2018 milestone Feb 5, 2018
@elliott-beach
Copy link

elliott-beach commented Feb 10, 2018

Here is the behavior in Atom, by the way (I couldn't figure out issue no. 2):

For csv.writer:

csv_writer

For constants:

x

This is using python2, atom 1.23.3, and autocomplete python 1.10.5. As to what version of Jedi they use, it's custom-patched, but available at https://github.com/autocomplete-python/autocomplete-python/tree/223e0c7ae2a97008c80709bac3d5d2c12807437a/lib/jedi.

@ghost
Copy link

ghost commented Feb 11, 2018

@segevfiner @DonJayamanne

So I'm sorry for being a little late, but here is an example of what I'm talking about. I must admit, at this time, since I have used Python in the 1.20 VSCode update (and I think a just before or just after update tot his extension) I at least seemingly have autocomplete on imports and classes, though I've come up with some areas short where it doesn't work. I still am not getting doc string definitions, or any other definitions when I hit F12 or cmd + click on anything. Goto definition has completely failed me still

I also want to note that if I use ctags at all, autocomplete stops working completely. I am not currently in a position to screen grab that but I can next week.

Here's some differences. the atom extension behaves 100 percent as I would expect a good python extension to do so.

screen shot 2018-02-10 at 5 54 29 pm

screen shot 2018-02-10 at 5 53 39 pm

I just want to point out that what I do get for add_url_rule is incorrectly defined.

and the atom extension

screen shot 2018-02-10 at 5 55 06 pm

@MikhailArkhipov
Copy link

Looks like this issue accumulated assorted cases. Jedi 0.11.1 (latest) was integrated. This works

image

Flask and go to definition also works

image

ARGUMENT_RE.match(p.description)] is fixed

I am going to close this one. Feel free to open separate issues for 2018.2 (you can try insider's build)

@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

5 participants