From bcb88047984989b37fa83e81e3a3206696115cb3 Mon Sep 17 00:00:00 2001 From: MarkoSagadin Date: Fri, 5 Jul 2024 12:17:16 +0200 Subject: [PATCH] Resolve invalid escape sequence '\.' warnings --- src/east/__main__.py | 2 +- src/east/helper_functions.py | 2 +- src/east/workspace_commands/codechecker_helpers.py | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/east/__main__.py b/src/east/__main__.py index e01f64b..068da5d 100644 --- a/src/east/__main__.py +++ b/src/east/__main__.py @@ -96,7 +96,7 @@ def cli(ctx, echo): \b \n\nWant to learn what each command does? - Run [bold]east \[command] --help[/] to show documentation for that command. + Run [bold]east \\[command] --help[/] to show documentation for that command. \b \n\nNote that commands are split into two groups: diff --git a/src/east/helper_functions.py b/src/east/helper_functions.py index 7a4a909..ac067e7 100644 --- a/src/east/helper_functions.py +++ b/src/east/helper_functions.py @@ -266,7 +266,7 @@ def dir_find(root, west_board): files = os.listdir(board_dir) # Find all files with west board name, no matter the version - pattern = f"^{west_board}_[0-9]?[0-9]?_[0-9]?[0-9]?_[0-9]?[0-9]?\.conf" + pattern = rf"^{west_board}_[0-9]?[0-9]?_[0-9]?[0-9]?_[0-9]?[0-9]?\.conf" matches = [file for file in files if re.match(pattern, file)] # Extract hardware versions and put them into format expected by the west. diff --git a/src/east/workspace_commands/codechecker_helpers.py b/src/east/workspace_commands/codechecker_helpers.py index 170da32..12a7fbd 100644 --- a/src/east/workspace_commands/codechecker_helpers.py +++ b/src/east/workspace_commands/codechecker_helpers.py @@ -132,6 +132,7 @@ def var_never_read_before_disabled_macro_found(files, diag): "unused variable '(.*)'", ] + var = None for desc_regex in desc_regexes: hit = re.search(desc_regex, diag["description"]) if hit: @@ -139,7 +140,7 @@ def var_never_read_before_disabled_macro_found(files, diag): var = hit.group(1) break - if not hit: + if not var: return False # A hit was found, locate the file where the diagnostic was found @@ -154,8 +155,8 @@ def var_never_read_before_disabled_macro_found(files, diag): # If you hit a line where variable is passed to __ASSERT* or LOG_* macro, # then this is a false positive, and should be removed patterns = [ - f".*__ASSERT.*\(.*{var}.*,.*", - f".*LOG_.*\(.*,.*{var}.*", + rf".*__ASSERT.*\(.*{var}.*,.*", + rf".*LOG_.*\(.*,.*{var}.*", ] for pattern in patterns: