Environment:
- Python 3.6.9
- VSCode
- Pylance
The structure of my workspace in VSCode is:
.../sync
├── README.rm
├── script-program-1
│ ├── lib
│ │ ├── __init__.py
│ │ └── queries.py
│ └── sync.py
├── lib
│ ├── __init__.py
│ ├── config.yaml
│ ├── logging.yaml
│ └── sync_config.py
└── requirements.txt
I've added "python.analysis.extraPaths": ["./lib"]
to settings.json located in sync\.vscode.
The issue is that within the sync.py script I'm having issues importing lib.queries.
If I try from .lib.queries import *
pylance doesn't complain but it fails with the error attempted relative import with no known parent package
If I instead use from lib.queries import *
python3 works as intended but pylance complains saying Import "lib.queries" could not be resolved(PylancereportMissingImports)
What can I change so that the import works AND pylance doesn't have an issue with it?
Update If I add ./script-program-1 to the settings.json python.analysis.extraPaths the problem goes away. The issue I have with this is that this project could have hundreds of "script-program-X" folders and all of them may have their own local import files. Updating this extraPaths variable for every one of them, on ever VSCode machine i work with, is not ideal.
I've tried using a variable like "./${relativeFileDirname}" as well as wild cards like "./**" and "./*but none of these work.
I know that the issue is caused because the workspace root is the sync folder and not script-program-1 but this is how I want it set up. Anyone have a solution to this?