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

Auto-import extremely unreliable for files inside workspace #139

Closed
daydev opened this issue Jul 19, 2020 · 6 comments
Closed

Auto-import extremely unreliable for files inside workspace #139

daydev opened this issue Jul 19, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@daydev
Copy link

daydev commented Jul 19, 2020

Environment data

  • Language Server version: 2020.7.2
  • OS and version: Linux Mint 20, VS Code 1.47.2
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.2

UPD: Also reproduced on Windows 8.1, VS Code 1.47.2, Python 3.8.4. The system didn't have neither VS Code, nor Python before today, completely clean case. No settings were changed after install other than: I installed Python and Pylance extensions, and I disabled linting. The abnormal behavior was the same, as shown on screenshots below.

Expected behaviour

Things in the workspace show up in auto-import suggestions.

Actual behaviour

Auto-import seems extremely unreliable when it comes to things in the workspace. Auto-import appears to discover names in the workspace only if the relevant file is opened and brought into focus. Some time later it may forget about them, even if the file remains open. I also tried changing Diagnostic Mode setting to "workspace", didn't seem to have any effect. Manual imports work fine, the suggestions are there. Additionally, if I write out a manual import and then remove it, the auto-import temporarily "learns" the path as well.

Additional information

I've attached some screenshots of a minimal example on a clean project:

  1. The suggestion to import from 'test' is not there.
  2. Once 'test.py' is opened, the suggestion appears.
  3. Contents of 'test.py'.
  4. Manual imports see the path always.

no-auto-1
no-auto-2
no-auto-3
no-auto-4

@erictraut
Copy link
Contributor

Thanks for the bug report. We're working on improving the behavior.

In the meantime, one way you can improve the behavior is to change the python.analysis.diagnosticMode setting to workspace. This will cause all of the files in your workspace to be analyzed. All symbols within all files will then be considered as candidates for auto-import.

@daydev
Copy link
Author

daydev commented Jul 19, 2020

Actually, as I mentioned in passing in the report, "python.analysis.diagnosticMode": "workspace" seems to have no impact on this issue. I tried it already before reporting and the behavior was the same. I confirmed just now that with "python.analysis.diagnosticMode": "workspace" it's the same. The setting itself is working because errors and warnings do show up from all across the project, but auto-imports are unchanged.

@judej judej added the enhancement New feature or request label Jul 20, 2020
@Leedehai
Copy link

Leedehai commented Jul 27, 2020

Thanks for working on it! In the meantime, I'm wondering if there is a way to just disable auto-imports (while keeping other features in place)? Can't find it in docs.

@jakebailey
Copy link
Member

There isn't a way at the moment, but we are working on all aspects of this (improving the suggestions, allowing control over which if any are shown, etc).

@heejaechang heejaechang added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Sep 2, 2020
@heejaechang
Copy link
Contributor

should be fixed in the next release.

@jakebailey jakebailey reopened this Sep 2, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.9.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202090-3-september-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

6 participants