In my python project, after upgrading mypy
from 0.770 to 0.782 an error is received in files where there were previously no type errors:
my_pkg_name\__init__.py: error: Source file found twice under different module names: 'top_pkg.my_pkg_name' and 'my_pkg_name'
Found 1 error in 1 file (checked 1 source file)
I'm pretty sure this is related to Issue #8944 on mypy and the way which vscode-python executes mypy on the open files. I've tried adding various mypy flags (e.g. --namespace-packages
, --no-namespace-packages
) but this did not resolve the issue.
my_pkg_name
does contain an __init__.py
and so does top_pkg
. With mypy==0.770
this was not a problem.
Looking at the extension's output this is how mypy is invoked:
> ~\.virtualenvs\OfflineSystem.38\Scripts\python.exe `
c:\Users\***\.vscode\extensions\ms-python.python-2020.8.108011\pythonFiles\pyvsc-run-isolated.py mypy `
--ignore-missing-imports --follow-imports=silent --show-column-numbers `
d:\***\top_pkg\my_pkg_name\sub_pkg\my_file.py
Should change something in the mypy-related vscode settings for this to work?
I had a similar issue, but not via VSCode. The fix in my case was to remove an __init__.py
file from a directory that was being included by adding it to the MYPYPATH, and so wasn't actually being treated as a module (so it shouldn't really have had the __init__.py
file).
You said you tried adding the --namespace-packages
flag, but I think you would need --no-namespace-packages
to disable the new checker which might be causing your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With