[Python] Pylance slows my VSCode's autocomplete to as much as 5-10 sec of wait for the dropdown

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    I discovered that Pylance was the source of my VSCode's autocomplete's slowness after following Visual Studio Code Intellisense is very slow - Is there anything I can do? and disabling all my extensions, then enabling them one by one. Pylance was the culprit.

    Now I have VS Code Pylance works slow with much delay telling me that the solution is "Try moving your code to its own folder and opening that up".

    But what does that mean? My project is small! The work of one developer maybe five hours a day for the past three months. Tiny!

    My hypothesis was that Pylance was scanning virtual environments. Mine is .venv. But no, it's not. See settings.json:

    {
    "python.formatting.provider": "autopep8",
    "editor.formatOnSave": true,
    "python.analysis.diagnosticMode": "workspace",
    "python.analysis.exclude": [
    "**/.venv/**",
    "**/alembic/**",
    "**/logs/**",
    "**/.pytest_cache/**",
    "**/DSScanner.egg-info/**"
    ]
    }



    So I have not been scanning virtual envs as I suspected.

    My original project structure was

    surveillance # project root
    ..src
    ....db
    ....service
    ....util
    ..tests
    ..server.py
    ..readme.md


    Claude suggested to me that perhaps Pylance was struggling reading all my relative imports. So, after putting it off for over a month, I redid my layouts to use absolute imports:

    surveillance # project root
    ..surveillance
    ....src
    ..tests
    ..readme.md


    This did not help me

    My pyrightconfig.json:

    {
    "include": ["surveillance", ""],
    "exclude": [
    ".venv",
    ".pytest_cache",
    "**/__pycache__",
    "deskSense.egg-info"
    ],
    "executionEnvironments": [
    {
    "root": ".",
    "extraPaths": ["."]
    }
    ],
    "typeCheckingMode": "basic",
    "useLibraryCodeForTypes": false
    }


    It's so slow, I must fix it. Can anyone suggest what is meant by "Try moving your code to its own folder"? Perhaps the problem is my monorepo? But I struggle to believe this, why would Pylance read my frontend folder, and other repos? They're tiny.

    Any other solution welcome of course

    Continue reading...

Compartilhe esta Página