When working with a Python project where I have the workspace root set to a subfolder, VS Code's Python extension doesn't correctly handle auto-import suggestions for modules that should be imported relative to the actual project root and I don't see any way to configure it properly.
Project Structure
project/
├── foo/ # <- Workspace root (opened folder)
│ ├── .vscode/
│ │ └── settings.json
│ ├── __init__.py
│ ├── bar.py
│ └── baz.py
├── other_modules/
└── __init__.py
Expected Behavior
Auto-import should suggest imports like:
from foo.bar import function
Actual Behavior
Auto-import suggests imports like:
from bar import function # Missing 'foo.' prefix
Settings Attempted
{
"python.analysis.extraPaths": ["${workspaceFolder}/.."],
"python.analysis.autoSearchPaths": true,
"python.analysis.include": ["${workspaceFolder}/.."],
"python.defaultInterpreterPath": "../.venv/bin/python"
}
Use Case
This is common in large projects where developers work primarily in sub-directories but need proper import resolution relative to the project root. Opening the parent directory as workspace root significantly impacts performance in large codebases.
Environment
VS Code version: 1.103.1
Python extension version: 2025.12.0
OS: Ubuntu 24.04
When working with a Python project where I have the workspace root set to a subfolder, VS Code's Python extension doesn't correctly handle auto-import suggestions for modules that should be imported relative to the actual project root and I don't see any way to configure it properly.
Project Structure
Expected Behavior
Auto-import should suggest imports like:
Actual Behavior
Auto-import suggests imports like:
Settings Attempted
{ "python.analysis.extraPaths": ["${workspaceFolder}/.."], "python.analysis.autoSearchPaths": true, "python.analysis.include": ["${workspaceFolder}/.."], "python.defaultInterpreterPath": "../.venv/bin/python" }Use Case
This is common in large projects where developers work primarily in sub-directories but need proper import resolution relative to the project root. Opening the parent directory as workspace root significantly impacts performance in large codebases.
Environment
VS Code version: 1.103.1
Python extension version: 2025.12.0
OS: Ubuntu 24.04