From 3d6c86ec574a7672ddc0ec67a4d1f5753e915004 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 2 Mar 2022 09:15:55 +0100 Subject: [PATCH] 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 --- util/cmake/condition_simplifier_cache.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) mode change 100644 => 100755 util/cmake/condition_simplifier_cache.py diff --git a/util/cmake/condition_simplifier_cache.py b/util/cmake/condition_simplifier_cache.py old mode 100644 new mode 100755 index 58cd5b88c5f..2023649347e --- a/util/cmake/condition_simplifier_cache.py +++ b/util/cmake/condition_simplifier_cache.py @@ -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 "