My project is structured as follows:
$ tree . -I venv
.
├── mydir
│ └── __init__.py
├── myotherdir
│ └── t.py
└── t.py
2 directories, 3 files
Both t.py
and myotherdir/t.py
have the same content:
$ cat t.py
import mydir
$ cat myotherdir/t.py
import mydir
Now, if I run mypy t.py
, then all works fine:
$ mypy t.py
Success: no issues found in 1 source file
However, if I run it from inside myotherdir
, then it's unable to find mydir
:
$ cd myotherdir/
$ mypy t.py
t.py:1: error: Cannot find implementation or library stub for module named 'mydir'
t.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
I was expecting that I would be able to solve this by modifying PYTHONPATH - however, that didn't work:
$ PYTHONPATH=.. mypy t.py
t.py:1: error: Cannot find implementation or library stub for module named 'mydir'
t.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
How can I let mypy
recognise mydir
when I'm running inside myotherdir
?