pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

convert import format code action not working with auto "src" detection

Open heejaechang opened this issue 5 months ago • 1 comments

put your code under "src" such as

src/a.py and b.py

and import from .b import foo from a.py and try to convert .b to b using code action.

currently, the code action doesn't understand auto extra path added by "src"

heejaechang avatar Jul 14 '25 21:07 heejaechang

Hi @heejaechang, I noticed you've already raised this issue. I believe the problem you're encountering isn't a bug in the code action itself, but rather a limitation in how the "src" folder structure is interpreted for imports.

To resolve it, you can add the src directory to your PYTHONPATH. For example:

export PYTHONPATH=$PYTHONPATH:./src Once the src folder is in the PYTHONPATH, the code action should work as expected when converting relative imports like from .b import foo to absolute ones like from b import foo.

Omshree3 avatar Aug 07 '25 11:08 Omshree3