Skip to content

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

Description

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

Activity

  1. brettcannon commented on Dec 11, 2017

    @brettcannon
    Member

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

  2. brettcannon commented on Jan 17, 2018

    @brettcannon
    Member

    Don Jayamanne (@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.

  3. segevfiner commented on Feb 1, 2018

    @segevfiner

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

  4. segevfiner commented on Feb 2, 2018

    @segevfiner
  5. segevfiner commented on Feb 3, 2018

    @segevfiner

    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.

  6. elliott-beach commented on Feb 10, 2018

    @elliott-beach

    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.

  7. MikhailArkhipov commented on Feb 17, 2018

    @MikhailArkhipov

    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)

  8. locked as resolved and limited conversation to collaborators on Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions