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

Selector for classes and functions not working when file is part of a project #15648

Closed
yves-surrel opened this issue May 18, 2021 · 10 comments
Closed

Comments

@yves-surrel
Copy link

yves-surrel commented May 18, 2021

Spyder 5.0, MacOs 11.2.1

Problem Description

The selector for classes and functions dropdown remain empty when the file is part of a project

What steps reproduce the problem?

  1. Edit a file that is not part of a project, from the file>Open menu. The dropdowns are filled OK.
  2. Make a project from the directory where the file is. Open the file by double-clicking on the project pane treeview. The dropdown remain empty.

I create a new issue since #13131 has been closed, and my title is more descriptive.

@steff456
Copy link
Member

Hi @yves-surrel,

Can you please update to the latest version of Spyder 5.0.2 via conda-forge or one of our installers and see if the error is still happening? Also, can you recall when was the previous version where this wasn't an issue?

@yves-surrel
Copy link
Author

Hi Stephannie
No change with Spyder 5.0.2.
However, my own investigations lead to an important information. The problem is only indirectly related to project creation. It seems to be more related to the PYTHONPATH content. When a project is created, a PYTHONPATH entry is created, as seen in the PYTHONPATH manager. When the project is deleted, the entry is automatically removed.

If I manually add an entry in the PYTHONPATH manager, the problem arises, but not always. In my case, although I do not know if it is a general rule, adding the parent or grandparent directory of the open file rises the problem.

I checked that the result param in DocumentProvider.process_document_symbol_request (spyder/plugins/completion/providers/languageserver/providers/document.py) returned different contents with and without an entry in PYTHONPATH. AFAIU it may be related to filling the symbols from the document, but I could not figure out where this is done (something to do with 'Langage Server Protocol' that I know nothing about).

@yves-surrel
Copy link
Author

In spyder/plugins/completion/providers/languageserver/providers/workspace.py, I made the following change:

class WorkspaceProvider:
    @send_notification(method=CompletionRequestTypes.WORKSPACE_CONFIGURATION_CHANGE)
    def send_configurations(self, configurations, *args):
        self.configurations = configurations
        params = {
            'settings': configurations
        }
        # ******** Added ************
        params['settings']['pyls']['plugins']['jedi']['extra_paths'] = []
        # ****************************
        return params

that removes what is added by changing the PYTHONPATH manually.

This fixes the problem when adding a path manually in the PYTHONPATH manager, however there is still the problem when creating a project (in all my trials, my test file is within the created project).

@yves-surrel
Copy link
Author

The thing broke between spyder versions 4.1.5 and 4.2.0

Output of conda install spyder=4.2.0

The following NEW packages will be INSTALLED:

  pyls-spyder        pkgs/main/noarch::pyls-spyder-0.3.2-pyhd3eb1b0_0

The following packages will be UPDATED:

  jedi                                        0.17.1-py38_0 --> 0.17.2-py38hecd8cb5_1
  python-language-s~                            0.35.1-py_0 --> 0.36.2-pyhd3eb1b0_0
  spyder                                       4.1.5-py38_0 --> 4.2.0-py38hecd8cb5_0
  spyder-kernels                               1.9.4-py38_0 --> 1.10.2-py38hecd8cb5_0

@ccordoba12
Copy link
Member

Hey @yves-surrel, thanks a lot for digging into this! That's really helpful.

This information will allow us to better debug and finally solve this problem.

@yves-surrel
Copy link
Author

Feel free to ask for any other test ;-)

@ccordoba12 ccordoba12 modified the milestones: v5.0.4, v5.1.0 May 24, 2021
@mrclary
Copy link
Contributor

mrclary commented May 27, 2021

This may be related, but I've also noticed that the class and function selector is empty for second editor panes.
Screen Shot 2021-05-27 at 8 51 17 AM

@mrclary
Copy link
Contributor

mrclary commented May 27, 2021

@yves-surrel, the OP issue may already be resolved; I cannot reproduce from bootstrap using the latest commit (d22f459). However, there are a couple of visible issues unrelated to the OP:

  • When creating a new project, the previously open file is closed and temp.py is opened. This is a result of closing open files when a project is opened, but the opened project doesn't have project files designated yet, so it defaults to temp.py
  • For conda bootstrapping, opening (or switching) a project can sometimes cause a traitlets kernel to die, causing a long delay for the console to restart.

class-selector

@yves-surrel
Copy link
Author

Still not working in Spyder 5.0.5

@ccordoba12 ccordoba12 assigned ccordoba12 and unassigned steff456 Jul 21, 2021
@ccordoba12
Copy link
Member

We're working to fix this problem in our next version (5.1.0), to be released at the end of the month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants