summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2019-10-10 15:56:57 +0200
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2019-10-10 14:59:55 +0000
commitc31f2683cc84b29b0044ec258b0055f6e5be4944 (patch)
treed07916440b4ed2809c9cb1e183a7b3cb5a845bb9
parent20f4f50a3a84cd0405990d83da008cb7aff2ceaa (diff)
cmake scripts: make pro_conversion_rate.py mypy clean
Change-Id: Id5b210361b6df61bb54324507fcff259cc4091e4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
-rwxr-xr-xutil/cmake/pro_conversion_rate.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/util/cmake/pro_conversion_rate.py b/util/cmake/pro_conversion_rate.py
index 1224f999a8..3c0c7e3070 100755
--- a/util/cmake/pro_conversion_rate.py
+++ b/util/cmake/pro_conversion_rate.py
@@ -43,6 +43,7 @@ from argparse import ArgumentParser
import os
import typing
+from typing import Dict, Union
from timeit import default_timer
@@ -94,7 +95,7 @@ class Blacklist:
return False
def is_blacklisted_part_aho(self, dir_path: str) -> bool:
- return self.tree.search(dir_path) is not None
+ return self.tree.search(dir_path) is not None # type: ignore
def recursive_scan(path: str, extension: str, result_paths: typing.List[str], blacklist: Blacklist):
@@ -124,7 +125,7 @@ def compute_stats(
existing_pros: int,
missing_pros: int,
) -> dict:
- stats = {}
+ stats: Dict[str, Dict[str, Union[str, int, float]]] = {}
stats["total projects"] = {"label": "Total pro files found", "value": total_pros}
stats["existing projects"] = {
"label": "Existing CMakeLists.txt files found",
@@ -142,17 +143,21 @@ def compute_stats(
for p in pros_with_missing_project:
rel_path = os.path.relpath(p, src_path)
if rel_path.startswith("examples"):
+ assert isinstance(stats["missing examples"]["value"], int)
stats["missing examples"]["value"] += 1
elif rel_path.startswith("tests"):
+ assert isinstance(stats["missing tests"]["value"], int)
stats["missing tests"]["value"] += 1
elif rel_path.startswith(os.path.join("src", "plugins")):
+ assert isinstance(stats["missing plugins"]["value"], int)
stats["missing plugins"]["value"] += 1
elif rel_path.startswith("src"):
+ assert isinstance(stats["missing src"]["value"], int)
stats["missing src"]["value"] += 1
for stat in stats:
- if stats[stat]["value"] > 0:
- stats[stat]["percentage"] = round(stats[stat]["value"] * 100 / total_pros, 2)
+ if int(stats[stat]["value"]) > 0:
+ stats[stat]["percentage"] = round(float(stats[stat]["value"]) * 100 / total_pros, 2)
return stats