We have a Python project with a src
directory where all our main code lives and the PYTHONPATH is set at the parent folder of src
, so not src
itself. We want to use the auto import function, but it keeps omitting the src
folder at the beginning.
We specifically use it when creating a class or variable that is not imported yet, Pylance detects it hasn’t been imported yet, and the quick fix pop-up shows. Pylance correctly finds the wanted class or variable, but omits the src
prefix.
What we want:
from src.foo.bar import Bar
But we got:
from foo.bar import Bar
when we use Bar()