skip to Main Content

I am currently able to use quick fix to auto import python functions from external typings such as from typing import List.

Python module quick fix import

However, I am unable to detect local functions/classes for import. For example: If I have the data class SampleDataClass in dataclasses.py, and I reference it in a function in test_file.py, VSCode is unable to detect it and I have to manually type out the import path for the dataclass.

Definition of dataclass

Reference to dataclass

I have the following extensions enabled:

  • Python
  • Pylance
  • Intellicode

My settings.json includes:

{
  "python.envFile": "${workspaceFolder}/.env",
  "python.languageServer": "Pylance",
  "python.analysis.indexing": true,
  "python.formatting.provider": "black",
  "python.analysis.autoImportCompletions": true,
  "python.analysis.autoSearchPaths": true,
  "python.autoComplete.extraPaths": ["~/Development/<django repo name>/server"],
  "python.analysis.extraPaths": ["~/Development/<django repo name>/server"],
  "vsintellicode.features.python.deepLearning": "enabled",
}

I am using poetry for my virtual environment which is located at ~/Development/<django repo name>/.venv

Is there something that I’m missing?

2

Answers


  1. Chosen as BEST ANSWER

    Turns out the latest versions for Pylance broke quick-fix imports and any extra path settings for VSCode. When I rolled back the version to v2022.8.50 it now works again.

    I filed an issue here: https://github.com/microsoft/pylance-release/issues/3353.


  2. According to an issue I raised in github earlier, the developer gave a reply.

    Custom code will not be added to the autocomplete list at this time (unless it has already been imported). This is done to prevent users from having too many custom modules, which may lead to too long loading time.

    If necessary, you can start a discussion in github and vote for it.

    Add:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search