From 8c21cf5e95794d588ee559f71b0f74563ba6708b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 17 Jun 2025 08:50:52 -0400 Subject: [PATCH] Make re strings be raw to avoid escape code warnings --- tools/check_board_header.py | 12 ++++++------ tools/extract_cmake_configs.py | 2 +- tools/extract_cmake_functions.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/check_board_header.py b/tools/check_board_header.py index da7b53408..79ca32f1a 100755 --- a/tools/check_board_header.py +++ b/tools/check_board_header.py @@ -130,7 +130,7 @@ def read_defines_from(header_file, defines_dict): if m: validity_stack.pop() continue - + if validity_stack[-1]: # look for "#include "foo.h" m = re.match(r"""^\s*#include\s+"(.+?)"\s*$""", line) @@ -220,12 +220,12 @@ def read_defines_from(header_file, defines_dict): line = re.sub(r"(?<=\S)\s*//.*$", "", line) # look for board-detection comment - if re.match("^\s*// For board detection", line): + if re.match(r"^\s*// For board detection", line): board_detection_is_next = True continue # check include-suggestion - m = re.match("^\s*// This header may be included by other board headers as \"(.+?)\"", line) + m = re.match(r"^\s*// This header may be included by other board headers as \"(.+?)\"", line) if m: include_suggestion = m.group(1) if include_suggestion == expected_include_suggestion: @@ -300,7 +300,7 @@ def read_defines_from(header_file, defines_dict): if m: validity_stack.pop() continue - + if validity_stack[-1]: # look for "#include "foo.h" m = re.match(r"""^\s*#include\s+"(.+?)"\s*$""", line) @@ -484,7 +484,7 @@ def read_defines_from(header_file, defines_dict): pins[define.resolved_value] = [define] # check for invalid DEFAULT mappings - m = re.match("^(PICO_DEFAULT_([A-Z0-9]+))_([A-Z0-9]+)_PIN$", name) + m = re.match(r"^(PICO_DEFAULT_([A-Z0-9]+))_([A-Z0-9]+)_PIN$", name) if m: instance_name = m.group(1) interface = m.group(2) @@ -506,7 +506,7 @@ def read_defines_from(header_file, defines_dict): raise Exception("{}:{} {} is set to {} which isn't a valid pin for {} on {} {}".format(board_header, define.lineno, name, define.resolved_value, function, interface, instance_num)) # check that each used DEFAULT interface includes (at least) the expected pin-functions - m = re.match("^PICO_DEFAULT_([A-Z0-9]+)$", name) + m = re.match(r"^PICO_DEFAULT_([A-Z0-9]+)$", name) if m: interface = m.group(1) if interface not in allowed_interfaces: diff --git a/tools/extract_cmake_configs.py b/tools/extract_cmake_configs.py index 18884330f..d24c939b4 100755 --- a/tools/extract_cmake_configs.py +++ b/tools/extract_cmake_configs.py @@ -139,7 +139,7 @@ def ValidateAttrs(config_name, config_attrs, file_path, linenum): elif BASE_CMAKE_CONFIG_RE.search(line): m = CMAKE_CONFIG_RE.match(line) if not m: - if re.match("^\s*#\s*# ", line): + if re.match(r"^\s*#\s*# ", line): logger.info("Possible misformatted {} at {}:{} ({})".format(BASE_CMAKE_CONFIG_NAME, file_path, linenum, line)) else: raise Exception("Found misformatted {} at {}:{} ({})".format(BASE_CMAKE_CONFIG_NAME, file_path, linenum, line)) diff --git a/tools/extract_cmake_functions.py b/tools/extract_cmake_functions.py index bc0b03ede..b58dc1b1d 100755 --- a/tools/extract_cmake_functions.py +++ b/tools/extract_cmake_functions.py @@ -123,7 +123,7 @@ def process_commands(description, name, group, signature): if any([';' in x for x in params]): logger.error("{}:{} has a parameter description containing ';'".format(group, name)) # Check that all parameters are in the signature - signature_words = set(re.split('\W+', signature)) + signature_words = set(re.split(r'\W+', signature)) for param in params: param_name = param.split(' ', maxsplit=1)[0] if param_name not in signature_words: