Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Auto imports should use existing import when possible #1965

Open
@mjbvz

Description

@mjbvz

Environment data

  • VS Code version: 1.44.0-insider
  • Extension version (available under the Extensions sidebar): 2020.4.68586-dev
  • OS and version: MacOS 10.15.3
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): NA
  • Relevant/affected Python packages and their versions: NA
  • Relevant/affected Python-related VS Code extensions and their versions: NA
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version vscode-python#3977): Language server
  • Value of the python.languageServer setting: Microsoft

Steps to reproduce:

  1. For a python file:
import time

sleep(1)
  1. Trigger auto imports on sleep and accept

Expected

Auto import use the existing time import

import time

time.sleep(1)

Actual

A second import or time is added

import time
from time import sleep

sleep(1)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions