vscode-python: intellisense suggests from incorrect module when using namespaces
Issue Type: Bug
Using python 3.8.0
Given directory structure
/src/foo/__init__.py
/src/foo/bar/__init__.py
/src/foo/bar/baz.py
/tests/__init__.py
/tests/foo/__init__.py
/tests/foo/bar/__init__.py
/tests/foo/bar/test_baz.py
where /src/foo/__init__.py
, /tests/__init__.py
, and /tests/foo/__init__.py
are used to designate namespace packages, with the following contents:
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Thus, 2 namespaces are created:
foo
and
tests.foo
with bar
being a non-namespace package in each
When editing /src/foo/bar/baz.py
…and typing foo.
in the editor…
Expected Result
intellisense displays suggestions from the foo.
module (foo.bar.baz
…)
Actual Result
intellisense ends up displaying suggestions from tests.foo
module, instead (foo.bar.test_baz
…)
Thus, e.g. typing foo.
in the editor will cause intellisense suggestions from tests.foo.
instead of from foo.
.
Workaround
Performing Developer: Reload Window
will resolve this.
Extension version: 2019.10.44104 VS Code version: Code 1.40.0 (86405ea23e3937316009fc27c9361deee66ffbf5, 2019-11-06T17:09:34.601Z) OS version: Darwin x64 18.7.0 Remote OS version: Linux x64 4.9.184-linuxkit
System Info
Item | Value |
---|---|
CPUs | Intel® Core™ i7-8750H CPU @ 2.20GHz (12 x 2200) |
GPU Status | 2d_canvas: enabled flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on oop_rasterization: disabled_off protected_video_decode: unavailable_off rasterization: enabled skia_renderer: disabled_off surface_control: disabled_off surface_synchronization: enabled_on video_decode: enabled viz_display_compositor: enabled_on viz_hit_test_surface_layer: disabled_off webgl: enabled webgl2: enabled |
Load (avg) | 4, 3, 3 |
Memory (System) | 16.00GB (0.31GB free) |
Process Argv | |
Screen Reader | no |
VM | 0% |
Item | Value |
---|---|
Remote | Dev Container: devbot |
OS | Linux x64 4.9.184-linuxkit |
CPUs | Intel® Core™ i7-8750H CPU @ 2.20GHz (6 x 2200) |
Memory (System) | 3.85GB (0.53GB free) |
VM | 0% |
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (3 by maintainers)
I have switched to the microsoft language server in the mean time (I was disabling it every time I needed to repro this).
The microsoft language server also has the benefit of “find all references” actually working correctly, whereas it does not work in Jedi.
However, the vscode containers in python also seem to take multiple executions of common commands for them to work. e.g. I often must open my workspace twice, as sometimes the first time it opens, the project’s folder listing never appears, and I have to “rebuild the dev container”.
Almost every time I change a python unittest, I have to click “run test” twice, as the first time it doesn’t run the rest (but seems to attempt to do a discovery run), instead.
I also have to run “find all references” twice for it to actually show any results.
These are among some of the issues that dev containers are riddle with (along with pretty awful UX, in general). Thus I wouldn’t be surprised if dev containers were also contributing to my issue.
If i get a chance to clone, sanitize, and create a reproduction with my current project I will share it, but it’s non-trivial work that I currently cannot spike on.
@eedwards-sk I have opened https://github.com/microsoft/vscode/issues/84738 to try to get VS Code to tweak their command to not leave our template out.