Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Fix "go to definition" and resolving imports #466

Description

I have "python.analysis.downloadChannel": "daily" activated.

The update two days ago broke the 'go to definition' feature for my setup.
I'm using vscode and it's regarding a large plone project using the omelette as described below.

To avoid language server load infinitely (which would be another issue, maybe related to this), I excluded the parts/omelette with search.exclude.
Below that in the settings, I added the parts/omelette with: "python.autoComplete.extraPaths": ["${workspaceFolder}/parts/omelette", ], which seemed to work for the last few days now.
By 'it seemed to work' I mean it could resolve the omelette imports and jump to definitions.
Now it sais 'no definition found for...' and the imports can't be resolved anymore.

For what I can see in the output, before the update, it used to analyse from autoComplete.extraPath, which it does not anymore since it updated the language server today.

(parts/omelette contains symlinks to cross-project sources in a local directory.)

Activity

  1. added a commit that references this issue on Dec 7, 2018
    9a9b269
  2. added a commit that references this issue on Dec 7, 2018
    5764f7e
  3. jakebailey commented on Dec 7, 2018

    @jakebailey
    Member

    Matthias Osswald (@busykoala) A new build with #467 is in progress and should show up in daily in a bit.

  4. busykoala commented on Dec 7, 2018

    @busykoala
    Author

    Thank you very much!

    The version I tried now, could resolve imports again with given settings.

    Not yet solved in my case is 'go to definition' which once was working properly (about three days ago).
    The output I get when trying to jump to a definition is following:

    [Error - 12:09:05 AM] Request textDocument/definition failed.
      Message: PriorityProducerConsumer`1 instance is disposed
    Object name: 'PriorityProducerConsumer`1'.
      Code: -32000 
       at Microsoft.PythonTools.Analysis.Infrastructure.DisposeToken.ThrowIfDisposed()
       at Microsoft.PythonTools.Analysis.Infrastructure.PriorityProducerConsumer`1.Produce(T value, Int32 priority)
       at Microsoft.PythonTools.Intellisense.AnalysisQueue.ExecuteInQueueAsync(Func`2 function, AnalysisPriority priority)
       at Microsoft.Python.LanguageServer.Implementation.Server.WaitForCompleteAnalysisWorker(CancellationToken cancellationToken)
       at Microsoft.Python.LanguageServer.Implementation.Server.FindReferences(ReferencesParams params, CancellationToken cancellationToken)
       at Microsoft.Python.LanguageServer.Implementation.Server.GotoDefinition(TextDocumentPositionParams params, CancellationToken cancellationToken)
       at Microsoft.Python.LanguageServer.Implementation.LanguageServer.GotoDefinition(JToken token, CancellationToken cancellationToken)
    

    Rather than this file structure some/other/package_x only is a symlink. This is pretty handy to have shared packages and is common use in plone projects.

    root
    │   main.py
    │
    ├───project
    │       __init__.py
    │
    └───some
        └───other
            └───package_x -> Users/username/.buildout/eggs/package_x
    

    As I mentioned to avoid infinit loading on 'go to definition' it yet (and still) is necessary to search exclude **/some/other.
    The folder is added again with "python.autoComplete.extraPaths":["${workspaceFolder}/some/other", ],

  5. jakebailey commented on Dec 7, 2018

    @jakebailey
    Member

    Is there an error message before that disposed message? That should only occur after an exception occurs in a different part of the code (#448), but the initial error should be in the same output panel.

  6. busykoala commented on Dec 7, 2018

    @busykoala
    Author

    Well I think it's not really an error message except of 'no definition found for...' in the vscode gui.

    Getting hover for package_name
    Waiting for parsing to complete.
    Parsing complete. Waiting for analysis entries to enqueue.
    Enqueue complete. Waiting for analysis to complete.
    [Error - 12:39:21 AM] Request textDocument/definition failed.
    

    But it doesn't seem to scan the additional files initially. So the output makes sense.

  7. AlexanderSher commented on Dec 7, 2018

    @AlexanderSher
    Contributor

    Matthias Osswald (@busykoala) , I've tried to recreate the file structure with symlink, but for me go to definition works as expected. If you have minimal repro, can you pack it into zip or tarball and attach to the bug?

  8. busykoala commented on Dec 8, 2018

    @busykoala
    Author

    I've just tried different repositories with the same structure.

    In smaller project it worked having these two lines in my settings:

    "python.autoComplete.extraPaths": ["${workspaceFolder}/parts/omelette", ],
    "python.autoComplete.typeshedPaths": ["${workspaceFolder}/parts/omelette", ],
    

    With bigger projects it's not working. Therefore I guess it is regarding the size of projects. I'm sorry I didn't figure that out before.

    Thank you for the help and let me try python language server when it advanced a little more.

  9. 24 remaining items

  10. MikhailArkhipov commented on Mar 28, 2019

    @MikhailArkhipov

    Matthias Osswald (@busykoala) - the exception should be fixed in 0.2.36 that is coming out ~ March 29th
    Once in a file from the omelette I couldn't go to definition at all (for my tested cases). - #840.

    Since the item is evolved with many cases fixed, I am closing it. Please open new issues for the cases you still discover. Thanks.

  11. erihanse commented on Apr 20, 2019

    @erihanse

    Has this stopped working again? It works with python.jediEnabled: true
    image

  12. jakebailey commented on Apr 22, 2019

    @jakebailey
    Member

    What is the message being squiggled? If the import isn't resolved, then it won't be able to find the definition.

  13. erihanse commented on Apr 22, 2019

    @erihanse

    I believe it's a linter complaining about lack of module documentation. The import should be valid.

  14. jakebailey commented on Apr 22, 2019

    @jakebailey
    Member

    A linter meaning an external linter, or a message generated by the language server? (It'll say (Python) in the hover if it's from the LS, otherwise the name of the linter.)

    Also, what's in your .env? Are you setting PYTHONPATH? Similarly, are you setting extraPaths in your VS Code settings?

  15. erihanse commented on Apr 22, 2019

    @erihanse

    It's an external, pydocstyle.
    image
    .env:

    PYTHONPATH="."
    

    I'm not setting extraPaths in vs code settings.

  16. erihanse commented on Apr 22, 2019

    @erihanse

    image
    When I hover it says it sees it as a module.

  17. jakebailey commented on Apr 22, 2019

    @jakebailey
    Member

    You're at the latest version, correct? I recently fixed some things related to setting a path to . (which should be redundant, as the opened folder itself is a search path). Are variables from that imported module accessible, or are they not listed?

    Since I think it's getting resolved, it's probably not related to the PYTHONPATH=. fixes. I'd appreciate it if you could open a new issue with that project attached (zipped, if you're willing to upload it).

  18. erihanse commented on Apr 22, 2019

    @erihanse

    I'm running 2019.3.6558 (8 April 2019) of vs code python extension. Not sure if there are any steps I need to do to upgrade LS? I'll create a new issue.

  19. jakebailey commented on Apr 22, 2019

    @jakebailey
    Member

    The LS version is different from the extension; you can find the language server version printed in the Python output panel (or in the directory name for the download inside the Python extension's folder).

  20. added a commit that references this issue on Nov 1, 2019
    4e26ee1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions