I have found other topics discussing namespace packages in vscode, but none describing how to handle composite namespace packages, and I cannot get these to work when added to the python path before opening vscode.
Here is an example structure:
├───core
│ ├───python
│ │ ├───common
│ │ │ ├───somecommonlib
│ │ └───package_a
│ │ └───somelib
In this example, common is a composite namespace package (it does not contain a __init__
file. package_a does contain a __init__
file.
in settings.json the key python.autoComplete.extraPaths only works for adding some path like core/python/package_a. It does not work for adding composite packages like core/python/common.
I have also tried adding core/python/common onto the PYTHONPATH before opening vscode in powershell (I’m in windows 10, using python 3.10 as my interpreter), but still autocompletion doesn’t work for any modules that exist in common.
Is there some crucial setting or feature I have missed to be able to get composite pacakges to work with the latest version of vscode (v1.93)?
mypy and pycharm both need these namespace packages explicitly marked. I dont know why since for the python interpreter, having core/python on the python path is all thats needed. But vscode doesn’t seem to have any awareness of what a namespace package is or how to handle a composite namespace package at all from my experimentation attempting to use them so far.
It turned out that everything I did is supposed to work, but what I didn’t realise was that something else was in the extraPaths from an old project clobbering the common namespace! So in case anyone else encounters this, start to debug by cleaning everything out and using a minimal environment.