Thank you very much for the help testing Jens, and the well thought reproducer.
I checked your example and I think I have an idea what is going on:
It would seem that mypy
is not taking into consideration the existence of finders defined outside of the stdlib.
Maybe I am wrong here, but I reached this conclusion after running importlib_resources.files(debugproject).glob("*")
and checking that py.typed
is indeed listed as part of debugproject
.
I believe that this limitation is closely related to the discussion in a different topic about PEP 660, IDEs and static code analysis. If we look at that thread and replace the occurrences of “IDE” with “static code analysis tool”, everything is pretty much applicable for this use case.
The TL;DR that I got from this other thread is that the packaging community is open to discuss different mechanisms to facilitate interoperating with static analysis tools, but this topic of conversation has not been explored yet.
On the bright side, if you install your project using the strict
mode, mypy seems to work well:
pip install -e . --config-settings editable-mode=strict
echo "from debugproject.foo import Foo" > test.py
.venv/bin/mypy test.py
# Success: no issues found in 1 source file
I also believe that projects using the src
-layout should work as normally.