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

Stub file not found on import but imported package has py.typed #555

Closed
jp-diegidio opened this issue Nov 3, 2020 · 8 comments
Closed
Labels
needs investigation Could be an issue - needs investigation

Comments

@jp-diegidio
Copy link

Hello guys, not sure this is a bug or me messing up, anyway here we go:

I have a namespaced package, let's call it some_ns.ext, that I install with pip -e. The code is annotated and I just include a py.typed. Here is the setup.py:

from setuptools import setup  # pyright: reportMissingTypeStubs=false
setup(name='some_ns.ext',
      version='0.0.1',
      namespace_packages=['some_ns'],
      package_dir={'': '.'},
      package_data={'some_ns.ext': ['py.typed']},
      packages=['some_ns.ext'])

But when I import in client code as follows:

from some_ns.ext.module1 import Class1

I still get a Stub file not found for "some_ns.ext.module1" Pylance (reportMissingTypeStubs).

I am not sure what I am doing wrong, since, per Pylance's docs as well as per issue #355, I'd expect it to just work.

(If I disable the warning, the rest works just fine, i.e. the imported objects do work, type-check and have intellisense as expected: the issue here seems confined to the import line.)

(For the chronicle, I also have python.analysis.useLibraryCodeForTypes = true and python.analysis.typeCheckingMode='strict' in my settings.)

Thank you,

Julio

  • Language Server: Pylance 2020.10.3 (pyright b881f28d)
  • OS and version: Windows 10 Home 20H2 (64-bit)
  • Python version: Python 3.8.5 (Conda 4.9.1)
@github-actions github-actions bot added the triage label Nov 3, 2020
@judej judej added the needs investigation Could be an issue - needs investigation label Nov 3, 2020
@github-actions github-actions bot removed the triage label Nov 3, 2020
@huguesv
Copy link
Contributor

huguesv commented Nov 3, 2020

@jp-diegidio thank you for the feedback.

Could you please put "python.analysis.logLevel": "Trace" in your settings, reload VS Code, open the file that produces the warning, and copy/paste the contents of the "Python Language Server" from Output window?

@jp-diegidio
Copy link
Author

Hi there,

I have meanwhile ascertained that it happens with all and only the packages that I install with pip --editable.

I am copying a little module that reproduces the problem, as well as the log (all names amended for privacy):

# x:\__ROOT__\__PROJ__\Project1\Source\base\module0.py

from project1.ext.module1 import Class1  # gives could not be resolved

Class1(int)  # everything fine here
[Info  - 23:52:03] Pylance language server 2020.10.3 (pyright b881f28d) starting
[Info  - 23:52:03] Server root directory: x:\__ROOT__\.vscode\extensions\ms-python.vscode-pylance-2020.10.3\dist
[Info  - 23:52:03] No configuration file found.
[Info  - 23:52:03] Setting pythonPath for service "Project1": "x:\__ROOT__\Programs\Anaconda3\envs\__ENV__\python.exe"
Search paths found for configured python interpreter:
  x:\__ROOT__\Programs\Anaconda3\envs\__ENV__\DLLs
  x:\__ROOT__\Programs\Anaconda3\envs\__ENV__\lib
  x:\__ROOT__\Programs\Anaconda3\envs\__ENV__
  x:\__ROOT__\Programs\Anaconda3\envs\__ENV__\lib\site-packages
  x:\__ROOT__\__PROJ__\project1\deploy\setup\base
  x:\__ROOT__\__PROJ__\project1\deploy\setup\ext
  x:\__ROOT__\Programs\Anaconda3\envs\__ENV__\lib\site-packages\win32
  x:\__ROOT__\Programs\Anaconda3\envs\__ENV__\lib\site-packages\win32\lib
  x:\__ROOT__\Programs\Anaconda3\envs\__ENV__\lib\site-packages\Pythonwin
[Info  - 23:52:04] Assuming Python version 3.8
[Info  - 23:52:04] Assuming Python platform Windows
[Info  - 23:52:04] Searching for source files
[Info  - 23:52:04] Found 196 source files
[Info  - 23:52:04] Background analysis(1) root directory: x:\__ROOT__\.vscode\extensions\ms-python.vscode-pylance-2020.10.3\dist
[Info  - 23:52:04] Background analysis(1) started
Background analysis message: setConfigOptions
Background analysis message: setTrackedFiles
Background analysis message: markAllFilesDirty
Background analysis message: setFileOpened
Background analysis message: getSemanticTokens
[BG(1)] parsing: x:\__ROOT__\__PROJ__\Project1\Source\base\module0.py (86ms)
[BG(1)] parsing: x:\__ROOT__\.vscode\extensions\ms-python.vscode-pylance-2020.10.3\dist\typeshed-fallback\stdlib\2and3\builtins.pyi [fs read 12ms] (471ms)
[BG(1)] binding: x:\__ROOT__\.vscode\extensions\ms-python.vscode-pylance-2020.10.3\dist\typeshed-fallback\stdlib\2and3\builtins.pyi (106ms)
[BG(1)] binding: x:\__ROOT__\__PROJ__\Project1\Source\base\module0.py (1ms)
[BG(1)] parsing: x:\__ROOT__\__PROJ__\project1\deploy\setup\ext\project1\ext\module1.py [fs read 6ms] (51ms)
[BG(1)] binding: x:\__ROOT__\__PROJ__\project1\deploy\setup\ext\project1\ext\module1.py (2ms)
[BG(1)] parsing: x:\__ROOT__\.vscode\extensions\ms-python.vscode-pylance-2020.10.3\dist\typeshed-fallback\stdlib\2and3\_typeshed\__init__.pyi [fs read 1ms] (49ms)
[BG(1)] binding: x:\__ROOT__\.vscode\extensions\ms-python.vscode-pylance-2020.10.3\dist\typeshed-fallback\stdlib\2and3\_typeshed\__init__.pyi (2ms)
[BG(1)] parsing: x:\__ROOT__\.vscode\extensions\ms-python.vscode-pylance-2020.10.3\dist\typeshed-fallback\third_party\2and3\typing_extensions.pyi [fs read 1ms] (17ms)
[BG(1)] binding: x:\__ROOT__\.vscode\extensions\ms-python.vscode-pylance-2020.10.3\dist\typeshed-fallback\third_party\2and3\typing_extensions.pyi (3ms)
[BG(1)] parsing: x:\__ROOT__\.vscode\extensions\ms-python.vscode-pylance-2020.10.3\dist\typeshed-fallback\stdlib\3\typing.pyi [fs read 0ms] (98ms)
[BG(1)] binding: x:\__ROOT__\.vscode\extensions\ms-python.vscode-pylance-2020.10.3\dist\typeshed-fallback\stdlib\3\typing.pyi (41ms)
Background analysis message: getSemanticTokens
Background analysis message: analyze
[BG(1)] analyzing: x:\__ROOT__\__PROJ__\Project1\Source\base\module0.py ...
[BG(1)]   checking: x:\__ROOT__\__PROJ__\Project1\Source\base\module0.py (4ms)
[BG(1)] analyzing: x:\__ROOT__\__PROJ__\Project1\Source\base\module0.py (5ms)
Background analysis message: resumeAnalysis

@jakebailey
Copy link
Member

Editable installs aren't an area we've fully tested yet: #78

@jp-diegidio
Copy link
Author

OK, I see: I hope this will be fixed soon as this is a totally standard development scenario...

Anyway, thanks for now.

@jakebailey
Copy link
Member

I'm going to close this as a dupe of #78, as that's the real problem with the resolution.

@jp-diegidio
Copy link
Author

I'm going to close this as a dupe of #78, as that's the real problem with the resolution.

Neither this is a dupe of that (at best that is a dupe of this), nor there is any resolution there, nor you call me out to test your proposed patch despite the quality of my feedback...

Thanks anyway!

@erictraut
Copy link
Contributor

Based on your report and trace information, this problem is a duplicate of #78. Both have the same root cause. Pyright previously didn't handle ".pth" files or symlinks, both of which are commonly used in editable installs. We've recently added support for these, so your problem should be addressed when the next version of pylance is released (next week). If you're still seeing this particular problem, we're happy to re-open the bug and look into it.

@jp-diegidio
Copy link
Author

Based on your report and trace information, this problem is a duplicate of #78.

I beg to disagree, most of that discussion is about intellisense: my issue is neither a duplicate of that one, nor, more importantly, on my book I can mark it as closed. You have later changed the title of #78, but in fact I am not against you consolidating there, it just went that way, with a little discomfort from my side but so be it: but I had to complain about the "lack of attention" that I got with the above replies and then with the follow-ups in #78. -- It's a little piece of customer feedback, nothing else: thanks for your reply and I'll look forward to the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation Could be an issue - needs investigation
Projects
None yet
Development

No branches or pull requests

5 participants