pro2cmake: Fix static type errors in condition_simplifier_cache.py

Mypy reported the following:

condition_simplifier_cache.py:111: error: Argument 1 has incompatible type "*List[str]"; expected
"Optional[float]"
            file_handle = file_open_func(*file_open_args, **file_open_kwargs)
                                          ^
condition_simplifier_cache.py:111: error: Argument 2 has incompatible type "**Dict[str, object]";
expected "Union[str, Path]"
            file_handle = file_open_func(*file_open_args, **file_open_kwargs)

Fix by calling portalocker.Lock directly.

Change-Id: I538319791b1a4a1b6dffac0544d87c705e8809a7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2022-03-02 09:15:55 +01:00
parent 5495eb9ec2
commit 3d6c86ec57

6
util/cmake/condition_simplifier_cache.py Normal file → Executable file
View File

@ -105,11 +105,7 @@ def open_file_safe(file_path: str, mode: str = "r+"):
try:
import portalocker # type: ignore
file_open_func = portalocker.Lock
file_open_args = [file_path]
file_open_kwargs = {"mode": mode, "flags": portalocker.LOCK_EX}
file_handle = file_open_func(*file_open_args, **file_open_kwargs)
return file_handle
return portalocker.Lock(file_path, mode=mode, flags=portalocker.LOCK_EX)
except ImportError:
print(
"The conversion script is missing a required package: portalocker. Please run "