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

Could not detect modules with the same name of current project in site-packages #895

Closed
ZeroAurora opened this issue Jan 29, 2021 · 4 comments
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@ZeroAurora
Copy link

I'm not a very good python programmer so there may be mistakes.

Well I'm looking through poetry's source code. Poetry seperates its build core as poetry-core from the original package poetry, which provides a module poetry.core. When installing, this module is installed into site-packages/poetry/core. But pylance only looks for the poetry folder under current project. Therefore, a reportMissingImports is raised.

Environment data

  • Language Server version: 2021.1.3 (pyright 61c53da4)
  • OS and version: Windows 10 with WSL2 (Debian Testing)
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.1

Expected behaviour

Import with no warnings.

Actual behaviour

A reportMissingImports warning is raised

Logs

(I've checked the log file and found no useful information.)

[Info  - 2:02:40 PM] No configuration file found.
[Info  - 2:02:40 PM] Setting pythonPath for service "poetry": "/home/zeroaurora/.cache/pypoetry/virtualenvs/poetry-BwIlo3xW-py3.9/bin/python3"
Search paths found for configured python interpreter:
  /usr/lib/python3.9
  /usr/lib/python3.9/lib-dynload
  /home/zeroaurora/.cache/pypoetry/virtualenvs/poetry-BwIlo3xW-py3.9/lib/python3.9/site-packages
  /home/zeroaurora/repos/poetry/tests/fixtures/extended_project_without_setup
  /home/zeroaurora/repos/poetry
  /home/zeroaurora/repos/poetry/tests/fixtures/simple_project
[Error - 2:02:40 PM] stubPath /home/zeroaurora/repos/poetry/typings is not a valid directory.
[Info  - 2:02:40 PM] Assuming Python version 3.9
[Info  - 2:02:40 PM] Assuming Python platform Linux
[Info  - 2:02:40 PM] Searching for source files
[Info  - 2:02:40 PM] Found 276 source files
Background analysis message: setConfigOptions
Background analysis message: setTrackedFiles
Background analysis message: markAllFilesDirty
Background analysis message: analyze
Background analysis message: setFileOpened
Background analysis message: getDiagnosticsForRange
[FG] parsing: /home/zeroaurora/repos/poetry/poetry/poetry.py (67ms)
[FG] parsing: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/builtins.pyi [fs read 1ms] (358ms)
[FG] binding: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/builtins.pyi (180ms)
[FG] binding: /home/zeroaurora/repos/poetry/poetry/poetry.py (5ms)
Background analysis message: analyze
[BG(1)] analyzing: /home/zeroaurora/repos/poetry/poetry/poetry.py ...
[BG(1)]   parsing: /home/zeroaurora/repos/poetry/poetry/poetry.py (44ms)
[BG(1)]   parsing: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/builtins.pyi [fs read 0ms] (187ms)
[BG(1)]   binding: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/builtins.pyi (118ms)
[BG(1)]   binding: /home/zeroaurora/repos/poetry/poetry/poetry.py (3ms)
[BG(1)]   checking: /home/zeroaurora/repos/poetry/poetry/poetry.py ...
[BG(1)]     parsing: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/2and3/__future__.pyi [fs read 1ms] (2ms)
[BG(1)]     binding: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/2and3/__future__.pyi (1ms)
[BG(1)]     parsing: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/2and3/_typeshed/__init__.pyi [fs read 0ms] (40ms)
[BG(1)]     binding: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/2and3/_typeshed/__init__.pyi (6ms)
[BG(1)]     parsing: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/third_party/2and3/typing_extensions.pyi [fs read 0ms] (7ms)
[BG(1)]     binding: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/third_party/2and3/typing_extensions.pyi (4ms)
[BG(1)]     parsing: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/typing.pyi [fs read 0ms] (58ms)
[BG(1)]     binding: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/typing.pyi (30ms)
[BG(1)]     parsing: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/pathlib.pyi [fs read 0ms] (23ms)
[BG(1)]     binding: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/pathlib.pyi (16ms)
[BG(1)]     parsing: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/os/__init__.pyi [fs read 0ms] (63ms)
[BG(1)]     binding: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/os/__init__.pyi (27ms)
[BG(1)]     parsing: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/abc.pyi [fs read 0ms] (1ms)
[BG(1)]     binding: /home/zeroaurora/.vscode-server/extensions/ms-python.vscode-pylance-2021.1.3/dist/typeshed-fallback/stdlib/3/abc.pyi (1ms)
[BG(1)]     parsing: /home/zeroaurora/repos/poetry/poetry/__version__.py [fs read 0ms] (0ms)
[BG(1)]     binding: /home/zeroaurora/repos/poetry/poetry/__version__.py (1ms)
[BG(1)]     parsing: /home/zeroaurora/repos/poetry/poetry/config/config.py [fs read 0ms] (21ms)
[BG(1)]     binding: /home/zeroaurora/repos/poetry/poetry/config/config.py (11ms)
[BG(1)]     parsing: /home/zeroaurora/repos/poetry/poetry/packages/__init__.py [fs read 0ms] (2ms)
[BG(1)]     binding: /home/zeroaurora/repos/poetry/poetry/packages/__init__.py (0ms)
[BG(1)]     parsing: /home/zeroaurora/repos/poetry/poetry/packages/locker.py [fs read 0ms] (134ms)
[BG(1)]     binding: /home/zeroaurora/repos/poetry/poetry/packages/locker.py (24ms)
[BG(1)]     parsing: /home/zeroaurora/repos/poetry/poetry/repositories/pool.py [fs read 0ms] (6ms)
[BG(1)]     binding: /home/zeroaurora/repos/poetry/poetry/repositories/pool.py (8ms)
[BG(1)]     parsing: /home/zeroaurora/repos/poetry/poetry/repositories/base_repository.py [fs read 1ms] (1ms)
[BG(1)]     binding: /home/zeroaurora/repos/poetry/poetry/repositories/base_repository.py (0ms)
[BG(1)]     parsing: /home/zeroaurora/repos/poetry/poetry/repositories/repository.py [fs read 1ms] (4ms)
[BG(1)]     binding: /home/zeroaurora/repos/poetry/poetry/repositories/repository.py (4ms)
[BG(1)]   checking: /home/zeroaurora/repos/poetry/poetry/poetry.py (624ms)
[BG(1)] analyzing: /home/zeroaurora/repos/poetry/poetry/poetry.py (978ms)
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: resumeAnalysis
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange

Code Snippet / Additional information

https://github.com/python-poetry/poetry/blob/master/poetry/poetry.py

@mvanderlee
Copy link

mvanderlee commented Jan 29, 2021

Duplicate of #892. Try reverting to v2021.1.2 for now.

I've confirmed that poetry uses pkgutil-style namespace:
https://github.com/python-poetry/poetry/blob/master/poetry/__init__.py

from pkgutil import extend_path


__path__ = extend_path(__path__, __name__)

@jakebailey
Copy link
Member

Yeah, I'm going to tentatively call this fixed via #892.

@jakebailey jakebailey added fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed triage labels Jan 29, 2021
@ZeroAurora
Copy link
Author

ZeroAurora commented Jan 30, 2021

Now that it's duplicated I'm closing it. Sorry for the inconvenience.

@jdwestbrook
Copy link

I am seeing the same problems on macos 11.2. For packages that include init.py
with path = import("pkgutil").extend_path(path, name).

Is there any update on when the fix for this will be released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

4 participants