pants: mypy plugin fails; site dir is in PYTHONPATH
I’ve been trying to update from pants 1.21.0 to 1.24.0 .
When I run this command (on both mac and linux)
./pants lint.mypy tool/::
I get an error just on the newer version of pants:
/Users/me/my_buildroot is in the PYTHONPATH. Please change directory so it is not.
This happens even if I pin mypy to 0.710, the version we were defaulting to with pants 1.21.0 .
You can seen here that mypy doesn’t want a folder to be both in PYTHONPATH and site packages: https://github.com/python/mypy/blob/v0.710/mypy/modulefinder.py#L488
One potentially unique feature of our repo is that we set pythonpath
in pants.ini to the root of our repo.
pythonpath: +[
"%(buildroot)s",
]
backend_packages: +[
"package.plugin1",
"package.plugin2",
]
However, I tried changing this global pythonpath config (which I think should only affect the python environment in which pants itself is running) and it didn’t seem to help.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (10 by maintainers)
Commits related to this issue
- Fix `PYTHONPATH` comingling in sitepackages. MyPy validates that packages aren't both available in site-packages and on the `PYTHONPATH`. Since we use `PYTHONPATH` to make certain packages visible to... — committed to jsirois/pants by jsirois 4 years ago
- Fix `PYTHONPATH` comingling in sitepackages. (#9690) MyPy validates that packages aren't both available in site-packages and on the `PYTHONPATH`. Since we use `PYTHONPATH` to make certain packages ... — committed to pantsbuild/pants by jsirois 4 years ago
Thank you both!
@RemiTorracinta although the fix appears to be straightforward I can’t reproduce the issue. Can you perhaps ammend this example repo such that it can be used to reproduce your issue?: https://github.com/pantsbuild/issues-9177
If I throw all the weirdness I can at it, mypy works just fine:
@Eric-Arellano has the relevant piece of code pointed out. The trick will be solving this style issue while not breaking the issue that code was added to fix.
Yep, 1.22.0.dev0 fails too.