autoImportCompletions implications for completion suggestions #7099
Replies: 1 comment
-
The auto-completion support in pyright is admittedly very limited. Microsoft's full-featured language server (pylance) builds on pyright and adds significantly more functionality in this regard including full indexing support that makes auto-completions more complete and responsive. Note, however, that pylance is licensed to use only with VS Code. It therefore won't work with sublime or other editors. We don't have plans at this time to further enhance the language server features in pyright. Those efforts are targeted at pylance, which has a full team backing it. The pylance team will fix basic bugs in pyright's existing language server features, but there are currently no plans to add new functionality or change the way existing functionality works in pyright. The focus of pyright is on core type checking functionality. If you would like to post a feature request or a bug report for language server features, the pylance issue tracker is a good place to do that. |
Beta Was this translation helpful? Give feedback.
-
I'm using pyright within Sublime Text and I was experimenting with the "python.analysis.autoImportCompletions" setting. At first I was just trying to prevent pyright from automatically adding import statements at the top of the file (I would accidentally accept a completion too often and then be surprised later by an extra import that I didn't add). It seems that this setting controls a lot more than that though.
With this setting ON it seems that completions draw from any python module which could conceivably be imported, so the list of completions is always long and most of the completions have very little relevance (the more relevant ones are of course generally higher in the list though).
With this setting OFF it seems that completions only draw from symbols that are currently imported, so the list tends to be shorter and much more relevant.
If the above is correct, I see the appeal of automatically adding import statements when desired, and pyright is quite good at it. For me at least, the autocomplete is so good that I can often just assume it'll get it right and type the first few chars (plus perhaps some well-chosen chars from later in the symbol due to the levenstein matching) then hit TAB without looking. Most of the time it is right and I can code really quickly. When it's wrong though it's faster to alt-backspace and try again rather than undo and end up with a partial symbol to deal with. So this workflow leads to stray imports at the top of the file with autoImportCompletions ON.
If my understanding of how this works is wrong then I'd greatly appreciate an explanation. If it's right then at the least it'd be great to update the documentation - I was really happy to discover the setting since it's made the completion suggestions a lot more relevant ever since I turned it off.
Finally if my workflow isn't terribly unique then it'd be great to have some way to invoke unimported completions separately since they are really quite rare compared to the need to type imported symbols (I realize this last one is a much bigger ask and potentially IDE-specific though!).
Regards,
Jeremy
Beta Was this translation helpful? Give feedback.
All reactions