Skip to content

mypy_cache conflicts with namespace packages #88

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

Open
brandonchinn178 opened this issue May 22, 2025 · 0 comments · May be fixed by #91
Open

mypy_cache conflicts with namespace packages #88

brandonchinn178 opened this issue May 22, 2025 · 0 comments · May be fixed by #91

Comments

@brandonchinn178
Copy link

brandonchinn178 commented May 22, 2025

Our project uses --explicit-package-bases and the default --namespace-packages. It seems like with these options, mypy will use a directory specified in MYPYPATH over a directory relative to CWD. rules_mypy creates .mypy_cache/ at bazel-out/*-fastbuild-*/bin/path/to/dir/dir.mypy_cache/ AND adds bazel-out/*-fastbuild-*/bin to MYPYPATH, causing it to find that directory instead of the path/to/dir/foo.py file in the standard file system.

I see generated_dirs is used to construct generated_import_dirs

generated_imports_dirs = []
for generated_dir in generated_dirs.keys():
for import_ in imports_dirs.keys():
generated_imports_dirs.append("{}/{}".format(generated_dir, import_))

Is there a reason why generated_dirs is added to MYPYPATH in addition to generated_import_dirs?

Related: python/mypy#19129

brandonchinn178 added a commit to brandonchinn178/rules_mypy that referenced this issue May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant