'VSCode appears to automatically be adding an import to the top of scripts

I am working on a Python project in VSCode with multiple files containing functions, being called from other files, like I have many other times. However, I noticed that, sometimes, the following line appears at the top of some files:

    from asyncore import read

I removed it, and now once I checked the file after altering others, it's back! It is making me go mad. It even is in the git push I did, although I am sure I removed it before sending it. Does anyone know what this is? Thank you.



Solution 1:[1]

You can disable it by adding this line to your user or workspace settings (File>Preferences>Settings, or Code>Preferences>Settings).

"python.analysis.autoImportCompletions": false

This Pylance extension setting is documented here. Turning of this setting is similar to this SO:answer except for Python instead of typescript.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SpeedCoder5