Skip to content

Microsoft Python Language Server fails to provide completions for an extension module #2466

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
segevfiner opened this issue Aug 30, 2018 · 7 comments
Labels
area-editor-* User-facing catch-all area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug

Comments

@segevfiner
Copy link

segevfiner commented Aug 30, 2018

Environment data

  • VS Code version: 1.26.1
  • Extension version (available under the Extensions sidebar): 2018.7.1
  • OS and version: Windows 10.0.17134.228 x64
  • Python version (& distribution if applicable, e.g. Anaconda): CPython 3.7.0 x64
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A

Actual behavior

Completion for the locally in-place built _hello extension module doesn't work. It shows the following warning:

Unable to resolve '_hello'. IntelliSense may be missing for this module.

Found in #2458 (comment)

Expected behavior

Completions should work.

Steps to reproduce:

  1. Download: hello_mod.zip
  2. Build it in-place: python setup.py build_ext --inplace (setuptools required)
  3. Open hello.py.

Logs

Output for Python in the Output panel:

Starting Microsoft Python language server.
[Info  - 9:12:56 PM] Created Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreter instance from Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreterFactory
Initializing for C:\Users\Segev\AppData\Local\Programs\Python\Python37\python.exe
Loading files from c:\Users\Segev\prj\hello_mod
##########Linting Output - flake8##########
1,1,F,F401:'_hello.hello' imported but unused

cc @brettcannon

@brettcannon brettcannon added bug Issue identified by VS Code Team member as probable bug area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. needs verification labels Aug 31, 2018
@brettcannon
Copy link
Member

I assume Python can import this module fine from where it is from within the extension? And have you tried with the 2018.8.0 release of the extension? I just checked if we had completions for _yaml from PyYAML and we do so it isn't inherent to extension modules.

And we are working on the documentation now, but you should be able to use "python.analysis.disabled": ["unresolved-import"] to turn off the warning.

@brettcannon brettcannon added info-needed Issue requires more information from poster and removed needs verification labels Sep 6, 2018
@segevfiner
Copy link
Author

I assume Python can import this module fine from where it is from within the extension? And have you tried with the 2018.8.0 release of the extension? I just checked if we had completions for _yaml from PyYAML and we do so it isn't inherent to extension modules.

I think the issue is specifically with extension modules built in-place that are not directly on sys.path (Not installed using setup.py develop or pip install -e). Please try the reproduction steps.

@brettcannon
Copy link
Member

Oh, if you can't import the file because it's not accessible from sys.path then the language server won't know where to look to find it. But the rest of your wording is suggesting that you can actually import and run the code fine (if that's wrong then let us know).

And I will try and verify this.

@brettcannon brettcannon added needs verification and removed info-needed Issue requires more information from poster labels Sep 7, 2018
@MikhailArkhipov
Copy link

You can try and add paths to python.completion.extraPaths

@brettcannon
Copy link
Member

To be clear of what is needed, if you run python setup.py build_ext --inplace you end up with a _hello.cpython-37m-darwin.so file next to the setup.py file at the top of the workspace folder. That is importable but the language server isn't picking it up as a file to analyze.

@luabud
Copy link
Member

luabud commented Sep 11, 2019

@MikhailArkhipov is this fixed in the LS?

@gramster gramster added the area-editor-* User-facing catch-all label Oct 10, 2019
@luabud
Copy link
Member

luabud commented Mar 11, 2020

Closing in favour of microsoft/python-language-server#197.

@luabud luabud closed this as completed Mar 11, 2020
@ghost ghost removed the needs upstream fix label Mar 11, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Mar 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-editor-* User-facing catch-all 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

6 participants