You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The exception "error: Cannot find implementation or library stub for module named "mypy_src_issue_example.a" is thrown for local files that are in scope, even when py.typing is added to the project. An example project is added here: mypy-local-import-issue-example, but the gist is that:
For a file src/my_project/a.py
deffoo() ->str:
...
and a file src/my_project/a.py
frommy_project.aimportfoofoo()
The following exception will be thrown:
my_project\b.py:1: error: Cannot find implementation or library stub for module named "my_project.a"
src\my_project\b.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 2 source files)
this happens with and without the following pyproject.toml config:
An alternative solution is to add a __init__.py file to the directory. This indicates that the directory is a python module.
Why might this solution not be working for me? I'm not entirely familiar with python modules but this didn't work whereas adding --namespace-packages=True worked.
Bug Report
The exception "error: Cannot find implementation or library stub for module named "mypy_src_issue_example.a" is thrown for local files that are in scope, even when
py.typing
is added to the project. An example project is added here: mypy-local-import-issue-example, but the gist is that:For a file
src/my_project/a.py
and a file
src/my_project/a.py
The following exception will be thrown:
this happens with and without the following
pyproject.toml
config:To Reproduce
I've stored a small examplary project here: mypy-local-import-issue-example
Expected Behavior
It should not throw any error since there is no reason why it shouldn't be able to resolve
src/my_project/a.py
.Your Environment
mypy.ini
(and other config files): see aboveThe text was updated successfully, but these errors were encountered: