-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
intellisense suggests from incorrect module when using namespaces #8551
Comments
Unfortunately you didn't fill our our issue template and so we don't know if you are using Jedi or the Microsoft language server? |
@brettcannon I opened this issue using the "Report Issue" feature in VSCode. If it's not using a template, the issue lies with that integration. python.jediEnabled appears to be true |
@eedwards-sk I have opened microsoft/vscode#84738 to try to get VS Code to tweak their command to not leave our template out. |
Hello @eedwards-sk, I couldn't reproduce your issue using the structure in your original comment and Do you have a sample repo I could use to try and reproduce your issue? Do you have other extensions installed? Also, could you copy the logs for the Python extension ( Thanks! |
I don't have a repro yet, just a workaround (reload window). I'll collect the log data as soon as I repro. I'm also running inside a dev container. |
Sorry for the distraction. This issue happened to me twice in a row on the same project, but I can't seem to get it to recur. I will close until I can repro with more debug data. |
Re-opening because it repro'd again.
|
Does it happen when you edit your code locally as well, or only when inside the container? I'm still not able to replicate your issue, could you provide a minimal reproducible example? The output logs you pasted are a good start, however they don't say whether you use Jedi or the Language Server, there should be a line saying One thing to try: does this behaviour happen if you don't have any open tabs with files from the |
I don't edit locally. I don't have a local python interpreter. Dev containers! This is the only reproducible setup right now and it's a proprietary private repo, thus my initial overview was an attempt at describing the project layout, but is not exhaustive. I can't reproduce it on demand so I can't generate a project that also reproduces it on demand until I can.
I already answered that above, when asked. It says jediEnabled is true, according to settings. I copied from the logs since the last save. Can you be more specific about what you need from the logs? You need everything in its entirety? Where is the file located? When the issue occurs it's often after a lot of data has already gone through the output log.
I'll try that next time it recurs. I'm seeing it happen when editing a python file from either of the namespaces ( |
For both user settings and workspace settings?
What I am looking for in order to be able to narrow down the issue is the content of the output channel once the extension finished activating.
That could help, yes.
Sadly there is no file, it's printed in the output channel as you go. |
Thank you! Here's a gist with the entirety of the log: https://gist.github.com/eedwards-sk/e320ef4fda09941c0891e2dbea87000e Confirmed the "jedi language server" starts at the top. Today I noticed something interesting. The problem was happening in reverse! As I was experimenting with opening / closing folders from I also confirmed that the namespaces aren't getting "merged", but somehow "masked / shadowed" by the other one. So I would assume that the root level of the namespace should make it unique. e.g. being a member of |
Thank you for the gist and for the different testing combinations! I still haven't been able to reproduce your issue either locally or in a Docker container, meanwhile we can try the following:
import jedi
with open('path/to/test_ecs_deploy.py') as file:
source = file.read()
script = jedi.Script(source=source, line=116, column=30) # index of the last . in from tests.snapkitchen....
completions = script.completions()
print(f"{len(completions)} completions available")
for c in completions:
print(f"name: {c.name}")
print(f"definition: {c.type}")
print(f"docstring: {c.docstring}") The output of this script is what Jedi returns (the extension only adds a thin wrapper to parse it), so if that's incorrect you will have to file an issue against Jedi. |
|
You have to adjust the |
Looks like jedi is surfacing the correct modules. with
with
yet vscode continues to display the incorrect list of modules: |
This is quite mystifying, since the only thing the extension does is format what's being returned by Jedi. Again, if you could provide a minimally reproducible example that would be extremely helpful. So to confirm, if you:
does it show |
Yes, but the intellisense is still incorrect in the editor. I don't have a minimally reproducible example available -- perhaps someone else who encounters this issue will be able to provide one. |
🤔 I am really sorry, sadly we reached a point where I would need to take a look at a project to understand what's going on... You also mentioned that you develop remotely using dev containers, which may or may not have an impact as well (I would assume it doesn't, but I would also assume that Intellisense provides correct suggestions). I will leave this issue open with the Again, I'm sorry I can't provide you with a conclusive answer. Thank you for your help so far! |
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. |
Since we can't get a stable reproducer I'm closing the issue, but if someone can provide one we can reopen this. |
Issue Type: Bug
Using python 3.8.0
Given directory structure
where
/src/foo/__init__.py
,/tests/__init__.py
, and/tests/foo/__init__.py
are used to designate namespace packages, with the following contents:Thus, 2 namespaces are created:
and
with
bar
being a non-namespace package in eachWhen 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 fromtests.foo.
instead of fromfoo.
.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
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
The text was updated successfully, but these errors were encountered: