aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2025-02-25 13:44:57 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2025-02-25 15:58:03 +0000
commitdf9e50ca8f48031b66e9791e8e8f5229f0a5a960 (patch)
treea7918333fa2276d5833fba494bf74db8315aecad /sources/pyside6
parent6a5d3dad739a3f27acef7d1980a126c53b0c3264 (diff)
type hints: Print erroneous PYI files for COIN support
Reason: We cannot find an error which happens in CI on Windows 11, only Task-number: PYSIDE-3012 Change-Id: I8f2e4c56ee8c81e8d3b348c624be5df80d5df275 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit b6952b833e1ec336607fd909320d35c5ca74a2a5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'sources/pyside6')
-rw-r--r--sources/pyside6/tests/pysidetest/mypy_correctness_test.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/sources/pyside6/tests/pysidetest/mypy_correctness_test.py b/sources/pyside6/tests/pysidetest/mypy_correctness_test.py
index fd253095b..0673d3e6e 100644
--- a/sources/pyside6/tests/pysidetest/mypy_correctness_test.py
+++ b/sources/pyside6/tests/pysidetest/mypy_correctness_test.py
@@ -3,6 +3,7 @@
from __future__ import annotations
import os
+import re
import sys
import unittest
import subprocess
@@ -28,6 +29,21 @@ is_ci = qtest_env == "ci"
USE_MYPY = True if is_ci else HAVE_MYPY
+def dump_erroneous_pyi_files(err_lines, pyi_dir):
+ seen = set()
+ for err_line in err_lines:
+ if match := re.search(r"Qt\w+\.pyi", err_line):
+ if (pyi := match.group(0)) not in seen:
+ seen.add(pyi)
+ print(f"----- dump of {pyi} -----")
+ with open(Path(pyi_dir) / pyi) as f:
+ line_no = 0
+ for line in f:
+ line_no += 1
+ print(f"{pyi}:{line_no} {line.rstrip()}")
+ print()
+
+
@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):
@@ -58,9 +74,13 @@ class MypyCorrectnessTest(unittest.TestCase):
time_pre = time.time()
ret = subprocess.run(cmd, capture_output=True)
time_post = time.time()
- for line in ret.stdout.decode("utf-8").split("\n"):
+ err_lines = ret.stdout.decode("utf-8").split("\n")
+ for line in err_lines:
print(line)
print(f"Time used for mypy test = {(time_post - time_pre):.5} s")
+ print(self.pyside_dir)
+ if ret.returncode != 0:
+ dump_erroneous_pyi_files(err_lines, self.pyside_dir)
self.assertEqual(ret.returncode, 0)