summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-07-30 15:56:37 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-07-31 12:55:33 +0200
commit4ed483b0e24b410b6bb240b48b4ad71e67877dc2 (patch)
tree1f20cd85ce81e71bfe759f87b607ae54a973a11f /util
parentca103f357c5dde9d39dc1d42ef53f02b5e632d43 (diff)
CMake: pro2cmake: Fix errors reported by flake8 and mypy
Change-Id: I842c0f8d7ec1d173fa1dbd74e769e2c370e70518 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'util')
-rw-r--r--util/cmake/Makefile2
-rwxr-xr-xutil/cmake/configurejson2cmake.py4
-rw-r--r--util/cmake/helper.py8
-rwxr-xr-xutil/cmake/pro2cmake.py17
-rw-r--r--util/cmake/qmake_parser.py6
5 files changed, 18 insertions, 19 deletions
diff --git a/util/cmake/Makefile b/util/cmake/Makefile
index 2243ad111e..f8fe4adf4e 100644
--- a/util/cmake/Makefile
+++ b/util/cmake/Makefile
@@ -11,7 +11,7 @@ black_format_check:
black *.py --line-length 100 --check
flake8:
- flake8 *.py --ignore=E501,E266,E203,W503
+ flake8 *.py --ignore=E501,E266,E203,W503,F541
pytest:
pytest
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py
index a443c4e842..d164f270f5 100755
--- a/util/cmake/configurejson2cmake.py
+++ b/util/cmake/configurejson2cmake.py
@@ -586,7 +586,7 @@ qt_config_compile_test("{config_test_name}"
if packages:
packages_string = " ".join(packages)
cm_fh.write(f" PACKAGES {packages_string}")
- cm_fh.write(f")\n")
+ cm_fh.write(")\n")
def write_compile_test(
@@ -1205,7 +1205,7 @@ def processSummaryHelper(ctx, entries, cm_fh):
entry_args_string = "".join(function_args)
cm_fh.write(f"qt_configure_add_summary_entry(\n{entry_args_string})\n")
elif "type" in entry and entry["type"] == "buildTypeAndConfig":
- cm_fh.write(f"qt_configure_add_summary_build_type_and_config()\n")
+ cm_fh.write("qt_configure_add_summary_build_type_and_config()\n")
elif "type" in entry and entry["type"] == "buildMode":
message = entry["message"]
cm_fh.write(f"qt_configure_add_summary_build_mode({message})\n")
diff --git a/util/cmake/helper.py b/util/cmake/helper.py
index a3edf30d08..02a241b018 100644
--- a/util/cmake/helper.py
+++ b/util/cmake/helper.py
@@ -760,12 +760,12 @@ def generate_find_package_info(
if cmake_target_name.endswith("_nolink") or cmake_target_name.endswith("/nolink"):
cmake_target_name = cmake_target_name[:-7]
- initial_package_name = lib.packageName
- package_name = initial_package_name
+ initial_package_name: str = lib.packageName if lib.packageName else ""
+ package_name: str = initial_package_name
if use_system_package_name:
replace_args = ["Wrap", "WrapSystem"]
- package_name = package_name.replace(*replace_args)
- cmake_target_name = cmake_target_name.replace(*replace_args)
+ package_name = package_name.replace(*replace_args) # type: ignore
+ cmake_target_name = cmake_target_name.replace(*replace_args) # type: ignore
if use_qt_find_package:
if cmake_target_name:
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index fd5410adf6..defadee3f3 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -50,7 +50,6 @@ import xml.etree.ElementTree as ET
from argparse import ArgumentParser
from textwrap import dedent
-from textwrap import indent as textwrap_indent
from functools import lru_cache
from shutil import copyfile
from collections import defaultdict
@@ -548,7 +547,7 @@ def write_add_qt_resource_call(
" PROPERTIES QT_SKIP_QUICKCOMPILER 1)\n\n"
)
- prefix_expanded = scope.expandString(prefix)
+ prefix_expanded = scope.expandString(str(prefix))
if prefix_expanded:
prefix = prefix_expanded
params = ""
@@ -1478,7 +1477,7 @@ def unwrap_if(input_string):
# Compute the grammar only once.
if not hasattr(unwrap_if, "if_grammar"):
- def handle_expr_with_parentheses(s, l, t):
+ def handle_expr_with_parentheses(s, l_unused, t):
# The following expression unwraps the condition via the
# additional info set by originalTextFor, thus returning the
# condition without parentheses.
@@ -3270,7 +3269,7 @@ def write_generic_library(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> s
return target_name
-def forward_target_info(scope: Scope, extra: [str], skip: Optional[Dict[str]] = None):
+def forward_target_info(scope: Scope, extra: List[str], skip: Optional[Dict[str, bool]] = None):
s = scope.get_string("QMAKE_TARGET_PRODUCT")
if s:
extra.append(f'TARGET_PRODUCT "{s}"')
@@ -3349,7 +3348,7 @@ def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
return target_name
-def write_tool(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
+def write_tool(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> Tuple[str, str]:
tool_name = scope.TARGET
if "force_bootstrap" in scope.get("CONFIG"):
@@ -3380,7 +3379,7 @@ def write_tool(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
def write_qt_app(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
app_name = scope.TARGET
- extra = []
+ extra: List[str] = []
target_info_skip = {}
target_info_skip["QMAKE_TARGET_DESCRIPTION"] = True
@@ -3493,8 +3492,8 @@ def write_find_package_section(
packages = [] # type: List[LibraryMapping]
all_libs = public_libs + private_libs
- for l in all_libs:
- info = find_library_info_for_target(l)
+ for one_lib in all_libs:
+ info = find_library_info_for_target(one_lib)
if info and info not in packages:
packages.append(info)
@@ -4154,7 +4153,7 @@ def create_top_level_cmake_conf():
try:
with open(conf_file_name, "x") as file:
file.write('set(QT_REPO_MODULE_VERSION "6.0.0")\n')
- except FileExistsError as _:
+ except FileExistsError:
pass
diff --git a/util/cmake/qmake_parser.py b/util/cmake/qmake_parser.py
index 2fabfe3f01..1b49ac7b58 100644
--- a/util/cmake/qmake_parser.py
+++ b/util/cmake/qmake_parser.py
@@ -71,9 +71,9 @@ def fixup_comments(contents: str) -> str:
return contents
-def flatten_list(l):
+def flatten_list(input_list):
""" Flattens an irregular nested list into a simple list."""
- for el in l:
+ for el in input_list:
if isinstance(el, collections.abc.Iterable) and not isinstance(el, (str, bytes)):
yield from flatten_list(el)
else:
@@ -227,7 +227,7 @@ class QmakeParser:
Option = add_element("Option", pp.Keyword("option") + CallArgs("option"))
RequiresCondition = add_element("RequiresCondition", pp.originalTextFor(pp.nestedExpr()))
- def parse_requires_condition(s, l, t):
+ def parse_requires_condition(s, l_unused, t):
# The following expression unwraps the condition via the additional info
# set by originalTextFor.
condition_without_parentheses = s[t._original_start + 1 : t._original_end - 1]