python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.5k stars 2.83k forks source link

--bazel ignoring --cache-dir #13216

Open thejcannon opened 2 years ago

thejcannon commented 2 years ago

Bug Report

If I run mypy --bazel --cache-dir .foo, all of the *.meta.json and *.data.json end up in CWD and below, instead of in .foo.

To Reproduce

(Write your steps here:)

  1. `mypy --bazel --cache-dir .foo ...
  2. Weep

Expected Behavior

The cache files would end up in .foo.

Actual Behavior

Kablammo all over CWD with JSON files and subdirs.

Your Environment

thejcannon commented 2 years ago

Found it :facepalm: https://github.com/python/mypy/blob/b0e59b29be239ce35cffcef20639709259ee48df/mypy/build.py#L1091

thejcannon commented 2 years ago

How would y'all feel about returning the cache dir if it's been set explicitly?

ph03 commented 1 year ago

This seems to be working

https://github.com/ph03/mypy/commit/093ad466502fa7ff2e33875606cf51aa7ef37388

and I was able to use an "external" cache folder from bazel using --sandbox_writable_path and passing --test_env=MYPY_CACHE_DIR=XXX for the target cache folder. But I'm not sure if there are other implications (like "bad" cache entries this way, as likely this option was set on purpose?)