'redundant import statement appears from nowhere in vscode

It's not the first time I've noticed that while editing python files in vscode import statement appears from nowhere, without my permission, like code below:

from unittest import result

What is it? How to prevent such insertions?



Solution 1:[1]

This happens because of auto import completion of Pylance. To disable this go to VSCode's Extensions tab, open Pylance settings and disable this setting.

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 ferrum