I'm working in VSCode with an AWS CDK project containing multiple Lambda function definitions - something like the below:
.
├── .venv
├── pyproject.toml
├── some_cdk_stuff.py
├── README.md
├── my_cool_folder
│ ├── __init__.py
│ ├── more_cdk_stuff.py
│ └── a_lambda_function
│ ├── world_domination.py
│ ├── main.py
│ └── requirements.txt
└── my_boring_folder
└── nested
└── another_lambda
├── main.py
├── stuff
│ ├── __init__.py
│ └── shopping.py
└── requirements.txt
My problem is that the VSCode linter is unable to resolve local imports at the roots of the (multiple) Lambda folders.
To be clear, my code works: It's not a question of fixing the local imports / __init__.py confusion - Just trying to get the linter/AutoComplete to understand the layout.
As discussed on this question - Lambda functions are run as scripts, not modules. So for example in a_lambda_function/main.py I would:
import world_domination
# And NOT add an __init__.py to switch to:
# from . import world_domination
I've seen answers like this one suggesting to add python.autoComplete.extraPaths in the .vscode/settings.json file, and this one suggesting a top-level .env file to configure PYTHONPATH...
...But as far as I can tell, those options would add visibility of every Lambda folder, everywhere in the project: For example shopping.py could import world_domination with no error?
Is there any way to set a configuration for a particular subfolder, to say "I'm a root folder. Within me, unqualified local imports are fine"?