Stop Importing My Typos

Most of the auto-complete features in Visual Studio Code are helpful. I have been using the Python extension which includes Pylance. Overall it’s a good experience, however I’ve had these weird import statements show up from time to time. The linter tells me an imported package is not being used, but I didn’t import that package (though the name of the package does look like a typo I just corrected).

It isn’t always typos. I found that I was trying to import the imp package a lot. Then I figured out I keep typing “im” or “imp” and hitting Tab thinking it would autocomplete as import. Instead it inserts import imp on a different line. This is not a fault in the extension – it is working as designed.

Given I don’t mind adding my own import statements, and I probably won’t stop making typos, I decided to turn off “Offer auto-import completions” in the VS Code settings for Pylance. That auto-completion is just not helpful for me with the kind of Python projects I’m working on now. I can always turn it back on if I miss it.

Animated GIF showing the auto-complete behavior and turning off the feature.