Mike DePalatis
Mike DePalatis

Reputation: 711

VSCode python extension: How can I disable autocompletion from inserting import statements?

In VS Code's Python extension I sometimes find that autocompletion can include options for things that are not yet imported in the file I'm editing. When selecting one of those options imports sometimes get inserted at the top of the module without notification. While I can see the utility in this feature I don't really like the behavior since it does this silently and puts them in alphabetical order disregarding any other sorting I may choose. Is there a way to disable this feature?

Upvotes: 15

Views: 5034

Answers (2)

jtunhag
jtunhag

Reputation: 185

Using Pylance (as of v2020.8.0), you can disable this by setting

"python.analysis.autoImportCompletions": false 

https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202080-5-august-2020

Upvotes: 17

Brett Cannon
Brett Cannon

Reputation: 15990

There currently isn't a way. You have a couple of options on how to deal with it:

  1. Make a feature request at https://github.com/microsoft/python-language-server
  2. Switch to Jedi as your intellisense engine
  3. Set up isort to sort your imports the way you want automatically

Upvotes: 1

Related Questions