-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mypy 0.780 source file found twice under different module names error #20
Comments
I just ran the aspect with This is interesting to me:
How exactly are you doing that, and why? ( |
Yes, I am using My repo looks like:
In mypy.ini I set If I go to |
Code to reproduce the error: File structure:
Contents:
startup --output_user_root=<some dir>
build --disk_cache=<some other dir>
build --aspects @mypy_integration//:mypy.bzl%mypy_aspect
build --output_groups=+mypy
build --action_env=PYTHONPATH=mylib
[mypy]
ignore_missing_imports = True
mypy_path = mylib
load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "bazelized",
srcs = glob(["bazelized/*.py"]),
deps = [],
)
def f(x: int) -> int:
return x Now the strange part:
# Expose f as "from welltyped.bazelized import f"
from welltyped.bazelize.x import f # !!! Comment this line and the error no longer appears ERROR on
output=$({MYPY_EXE} {VERBOSE_OPT} --bazel --package-root mylib --config-file {MYPY_INI_PATH} --cache-map {CACHE_MAP_TRIPLES} -- {SRCS} 2>&1) The problem with --package-root is that it only allows one root AFAIK. |
Thanks for reproduction. I'll take a look. |
Hmm. I'm trying to figure out the solution here. Collect up the |
#29 addresses this by using |
This bazel plugin works well with mypy 0.770 but after upgrading to 0.780 it complains with
"source file found twice under different module names error". mypy 0.780 works fine outside of bazel.
There is a related issue on mypy: python/mypy#8944. In my case, directories on
mypy_path
do not contain__init__.py
files.mypy_path
withinmypy.ini
. Even if I disable that, the problem persists.$(pwd)
to the front of MYPYPATH. I tried playing around with that but still hitting the same issue.So, I am not very sure where the problem comes from.
EDIT: usually I am setting PYTHONPATH in .bazelrc and mypy_path in mypy.ini but even if I add
imports = ["<path e.g. ..>"]
in all BUILD files the above steps still apply.The text was updated successfully, but these errors were encountered: