Skip to content

Commit cc1164d

Browse files
committed
type hints: Make the mypy cache more permanent
By default, mypy stores its cache data in $(pwd)/.mypy_cache . It is better to save it in the pyside_setup folder under a version specific name. This makes the cache survive full rebuilds. We tested that this folder is really writable. Task-number: PYSIDE-2846 Change-Id: I739e74cb24b5aaa1b2b457195e8a143b56a2bc44 Pick-to: 6.8 6.8.0 Reviewed-by: Friedemann Kleint <[email protected]>
1 parent c37642f commit cc1164d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sources/pyside6/tests/pysidetest/mypy_correctness_test.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,20 @@ def setUp(self):
3131
self.pyside_dir = Path(PySide6.__file__).parent
3232
self.build_dir = self.pyside_dir.parent.parent
3333
os.chdir(self.build_dir)
34+
self.project_dir = Path(__file__).resolve().parents[4]
35+
# Check if the project dir can be written. If so, put the mypy cache there.
36+
test_fname = self.project_dir / ".tmp test writable"
37+
try:
38+
with test_fname.open("w") as f:
39+
f.write("works!")
40+
f.close()
41+
test_fname.unlink()
42+
self.cache_dir = self.project_dir / f".pyside{PySide6.__version__}_mypy_cache"
43+
except Exception:
44+
self.cache_dir = ".mypy_cache" # This is the mypy default.
3445

3546
def testMypy(self):
36-
cmd = [sys.executable, "-m", "mypy", f"{os.fspath(self.pyside_dir)}"]
47+
cmd = [sys.executable, "-m", "mypy", "--cache-dir", self.cache_dir, self.pyside_dir]
3748
time_pre = time.time()
3849
ret = subprocess.run(cmd, capture_output=True)
3950
time_post = time.time()

0 commit comments

Comments
 (0)