Skip to content

Commit be4e09c

Browse files
committed
type hints: Make the mypy cache more permanent, amended
It turned out that mypy is not loaded by COIN tests when requirements_coin.txt is used. Also enforce mypy existence in COIN to prevent further configuration errors. As a drive-by, a new cache is used that is > 10% faster. Task-number: PYSIDE-2846 Change-Id: I75a27cfd0cb0fb0d7cd44c2a121291af052b0d8f Pick-to: 6.8 6.8.0 Reviewed-by: Cristian Maureira-Fredes <[email protected]>
1 parent 07ee315 commit be4e09c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

requirements-coin.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ importlib_metadata>=6
1010
tomli>=2.0.1
1111
wheel>=0.43.0
1212
platformdirs >= 2.6.2
13-
mypy>=1.11.2

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ patchelf==0.17.2; sys_platform == 'linux'
88
# 1.24.4 is the last version that supports Python 3.8
99
numpy<1.25; python_version < '3.9'
1010
numpy==1.26.3; python_version >= '3.9'
11+
mypy[faster-cache]>=1.13.0

sources/pyside6/tests/pysidetest/mypy_correctness_test.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@
2222
import PySide6
2323
from PySide6 import SKIP_MYPY_TEST
2424

25+
qtest_env = os.environ.get("QTEST_ENVIRONMENT", "")
26+
is_ci = qtest_env == "ci"
27+
# When we are in COIN, we enforce mypy existence, to prevent misconfigurations.
28+
USE_MYPY = True if is_ci else HAVE_MYPY
2529

26-
@unittest.skipIf(not HAVE_MYPY, "The mypy test was skipped because mypy is not installed")
30+
31+
@unittest.skipIf(not USE_MYPY, "The mypy test was skipped because mypy is not installed")
2732
@unittest.skipIf(SKIP_MYPY_TEST, "The mypy test was disabled")
2833
class MypyCorrectnessTest(unittest.TestCase):
2934

@@ -32,6 +37,8 @@ def setUp(self):
3237
self.build_dir = self.pyside_dir.parent.parent
3338
os.chdir(self.build_dir)
3439
self.project_dir = Path(__file__).resolve().parents[4]
40+
# For safety about future changes, check that we are sitting above the sources dir.
41+
self.assertTrue((self.project_dir / "sources").exists())
3542
# Check if the project dir can be written. If so, put the mypy cache there.
3643
test_fname = self.project_dir / ".tmp test writable"
3744
try:
@@ -44,6 +51,7 @@ def setUp(self):
4451
self.cache_dir = ".mypy_cache" # This is the mypy default.
4552

4653
def testMypy(self):
54+
self.assertTrue(HAVE_MYPY)
4755
cmd = [sys.executable, "-m", "mypy", "--cache-dir", self.cache_dir, self.pyside_dir]
4856
time_pre = time.time()
4957
ret = subprocess.run(cmd, capture_output=True)

0 commit comments

Comments
 (0)