I am trying to set MYPYPATH to find a library located in another directory. I am importing a function like this:
from my_module import my_function
The file structure:
function
|__lib1
| |__lib2
| |__my_module.py
|__function1
|__src
|__index.py <-- this is the file where my_module is imported
The file structure has to be like this because these are AWS Lambdas (lib1
is the Lambda layer here).
I am using the following tox configuration:
skipsdist = True
envlist = mypy
[testenv]
deps = -r requirements.txt
[testenv:mypy]
commands = mypy --namespace-packages -p function -p test
I tried setting:
setenv = MYPYPATH = './function/lib1/lib2'
setenv = MYPYPATH = './function/lib1/lib2/my_module.py'
as well as
mypy_path = 'function/lib1/lib2'
mypy_path = 'function/lib1/lib2/my_module.py'
I tried full path instead of relative path as well.
However, I'm still getting the same error: error: Cannot find implementation or library stub for module named my_module
.
This is not a tox issue, as running mypy --namespace-packages -p function -p test
alone produces the same error.
Is there a way to make it work?