question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

intellisense suggests from incorrect module when using namespaces

See original GitHub issue

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%

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
eedwards-skcommented, Nov 27, 2019

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.

1reaction
brettcannoncommented, Nov 13, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intellisense doesn't work at all with C++20 Modules
In this solution, IntelliSense does not recognize any import statements. As soon as I remove the extra include entry in Project Settings ->...
Read more >
prompts don't work correctly when using @use with namespace
It works, but it means you can't use anything like namespaces. In addition, placeholder selectors from modules don't show up on IntelliSense at...
Read more >
Namespaces and Autocomplete - Autodesk
Namespaces. In Python, all variables, functions and module names are in either the local namespace (restricted to a function) or in the global...
Read more >
Visual Studio 2017 intellisense saying namespace is used like ...
Visual Studio out of literally nowhere started complaining that I'm using InsanityStore (which is a class) as a "namespace".
Read more >
Resolve IntelliSense Issue in Visual Studio Code [Fixed]
1 Use Keyboard Help; 2 Check Settings.json is changed; 3 Restart VSCode; 4 Update VSCode; 5 Select Correct programming Language Mode ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found