diff options
| author | Christian Tismer <tismer@stackless.com> | 2024-11-01 13:07:39 +0100 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2024-11-04 12:30:07 +0100 |
| commit | be4e09c4fbda0844f16f2f064e5352f8eb1b60f0 (patch) | |
| tree | dba7be9406c0e8de79606fe88f13a49c6218a6be | |
| parent | 07ee31548a3af6552e62625860c20772503e658c (diff) | |
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 <cristian.maureira-fredes@qt.io>
| -rw-r--r-- | requirements-coin.txt | 1 | ||||
| -rw-r--r-- | requirements.txt | 1 | ||||
| -rw-r--r-- | sources/pyside6/tests/pysidetest/mypy_correctness_test.py | 10 |
3 files changed, 10 insertions, 2 deletions
diff --git a/requirements-coin.txt b/requirements-coin.txt index fd898f04f..5ee2bac0d 100644 --- a/requirements-coin.txt +++ b/requirements-coin.txt @@ -10,4 +10,3 @@ importlib_metadata>=6 tomli>=2.0.1 wheel>=0.43.0 platformdirs >= 2.6.2 -mypy>=1.11.2 diff --git a/requirements.txt b/requirements.txt index 281aef062..96d8be52d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ patchelf==0.17.2; sys_platform == 'linux' # 1.24.4 is the last version that supports Python 3.8 numpy<1.25; python_version < '3.9' numpy==1.26.3; python_version >= '3.9' +mypy[faster-cache]>=1.13.0 diff --git a/sources/pyside6/tests/pysidetest/mypy_correctness_test.py b/sources/pyside6/tests/pysidetest/mypy_correctness_test.py index bad35a2f3..5f94f82ab 100644 --- a/sources/pyside6/tests/pysidetest/mypy_correctness_test.py +++ b/sources/pyside6/tests/pysidetest/mypy_correctness_test.py @@ -22,8 +22,13 @@ except ModuleNotFoundError: import PySide6 from PySide6 import SKIP_MYPY_TEST +qtest_env = os.environ.get("QTEST_ENVIRONMENT", "") +is_ci = qtest_env == "ci" +# When we are in COIN, we enforce mypy existence, to prevent misconfigurations. +USE_MYPY = True if is_ci else HAVE_MYPY -@unittest.skipIf(not HAVE_MYPY, "The mypy test was skipped because mypy is not installed") + +@unittest.skipIf(not USE_MYPY, "The mypy test was skipped because mypy is not installed") @unittest.skipIf(SKIP_MYPY_TEST, "The mypy test was disabled") class MypyCorrectnessTest(unittest.TestCase): @@ -32,6 +37,8 @@ class MypyCorrectnessTest(unittest.TestCase): self.build_dir = self.pyside_dir.parent.parent os.chdir(self.build_dir) self.project_dir = Path(__file__).resolve().parents[4] + # For safety about future changes, check that we are sitting above the sources dir. + self.assertTrue((self.project_dir / "sources").exists()) # Check if the project dir can be written. If so, put the mypy cache there. test_fname = self.project_dir / ".tmp test writable" try: @@ -44,6 +51,7 @@ class MypyCorrectnessTest(unittest.TestCase): self.cache_dir = ".mypy_cache" # This is the mypy default. def testMypy(self): + self.assertTrue(HAVE_MYPY) cmd = [sys.executable, "-m", "mypy", "--cache-dir", self.cache_dir, self.pyside_dir] time_pre = time.time() ret = subprocess.run(cmd, capture_output=True) |
