Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python.analysis.extrapaths setting breaks when more than 1 folder in workspace #6925

Open
ZBB-XD opened this issue Feb 6, 2025 · 3 comments
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@ZBB-XD
Copy link

ZBB-XD commented Feb 6, 2025

Environment data

  • Pylance version: 2025.2.1
  • OS and version: Windows 11
  • Python version (& distribution if applicable, e.g. Anaconda): XXX

Code Snippet

# No python code needed

Repro Steps

  1. Create the following folders: C:/mainFolder/SubFolder, C:/mainFolder/SubFolder2, C:/mainFolder/3rdParty, C:/mainFolder/3rdParty/myExamplePackage
  2. Create the following file: C:/mainFolder/3rdParty/myExamplePackage/_ _ init _ _ .py (markdown is screwing this up, use dunders)
  3. Open VS Code and then click File>Open Folder. Select C:/mainFolder/SubFolder
  4. Click File>NewFile and make a new python file.
  5. In the new python file, type "import myExamplePackage"
  6. NOTE that there IS a pylance unresolved import error.
  7. In File > Preferences > Settings, change your Workspace > Python>Analysis>ExtraPaths to include the following: "../3rdParty"
  8. in the file from step 5, notice that the import error goes away
  9. in the Explorer pane, right click in the white space under your SubFolder(Workspace) section
  10. Click "Add Folder to Workspace"
  11. Select C:/mainFolder/SubFolder2
  12. Look at the file from step 5

Expected behavior

'Import myExamplePackage' stays resolved

Actual behavior

Import does not resolve again. Sometimes it has pylance eror, other times myExamplePackage turns white and uninteractable.
If you remove the added SubFolder2, sometimes it remains broken until you close the window and reopen the workspace.

Logs

No logs needed

Extra Notes

I have many problems with analysis extra paths. I have variations of this same problem and no amount of absolute pathing or relative pathing fixes my imports. All of these appear to be caused by having more than 1 folder in a workspace.

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Feb 6, 2025
@ZBB-XD
Copy link
Author

ZBB-XD commented Feb 6, 2025

Also please note that changing the Python analysis extrapaths for both project folders, which supersedes the workspace setting, doesnt work either. Neither does changing the User version of extrapaths either

@Hnasar
Copy link

Hnasar commented Feb 6, 2025

+1 This is an urgent fix for us, this is breaking all of our pylance features for me and my coworkers.

@rchiodo
Copy link
Contributor

rchiodo commented Feb 6, 2025

+1 This is an urgent fix for us, this is breaking all of our pylance features for me and my coworkers.

Are you saying this is a regression? That in 2024.12.1 it works fine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

4 participants