I was wondering how do you guys setup vs code to handle your imported custom modules with working intellisense? I have a “global” lib folder with all of my often used functions, and I have it’s path added to
"python.autoComplete.extraPaths" but I would also like to do the same in a smaller context, like for stacks or pulldowns, just like @eirannejad did it with the memo stack:
Here importing the
copypastestate module works fine in the scripts, but in vs code autocomplete doesn’t work, and the linter also throws errors.
something along these lines in your config?
the . or … notation for the lib folder means it is going for the lib at folder level or up one folder.
It should work if you open the
memo.stack folder in vscode if I take this as an example.
not ideal, but not that bad either
I guess your solution only works because your workspace root folder is directly above
lib in your case, and I’ve found that items in the
extraPaths array are always relative to the workspace root, or absolute, but can’t use the current file’s folder as the relative base. Unfortunately opening the
stack folder in another workspace would mean to reconfigure all the workspace settings, and replace the extension level lib folder’s relative path to an absolute path, otherwise that would be unaccessible. It is better than nothing as a workaround, but yeah, it is not ideal
Upvote this github discussion to add globs in extraPaths!
Unfortunately it’s almost three years since the request was opened, but microsofd didn’t show any love
The problem, though, is that once you have all the
lib folders in the
extraPaths, everything would seem available to all the buttons, even the ones in another panel/tab.
I would solve it once and for all with a single
lib folder at the project root, so that every button can load it. If you need to organize the modules, just create packages in them (that is, folders with the
__init__.py file in them).
Yes, that’s what I plan to do, have some generic modules, and tool specific modules under the root lib. I’ve also found the extraPaths feature requests, but I got disappointed seeing nothing has happened.