From f77d25039b90d603dc5bdbb487d77e3b89345072 Mon Sep 17 00:00:00 2001 From: Stefan Vigerske Date: Fri, 6 Jun 2025 12:25:26 +0200 Subject: [PATCH] declare more strings as regular expressions - fixes warnings or errors with current python --- migrate.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/migrate.py b/migrate.py index c66871ed08..550ed33771 100755 --- a/migrate.py +++ b/migrate.py @@ -376,8 +376,8 @@ def read_closing_commits(): RE_UNDERLINED_CODE2 = re.compile(r'(?<=\s)_([a-zA-Z_]+)_$') RE_UNDERLINED_CODE3 = re.compile(r'^_([a-zA-Z_]+)_(?=\s)') RE_CODE_SNIPPET = re.compile(r'(?([a-zA-Z]+)') @@ -694,7 +694,7 @@ def commits_list(match): if m: commit_id = m.group(1) commit_url = m.group(2) - commit_msg = m.group(3).replace('\`', '`') + commit_msg = m.group(3).replace(r'\`', '`') t += r'{}{}'.format(commit_url, commit_id, commit_msg) else: m = RE_COMMIT_LIST2.match(c) @@ -792,10 +792,10 @@ def heading_replace(match): if not (in_code or in_html): # quote prefix = '' - m = re.match('^((?:>\s)*>\s)', line) + m = re.match(r'^((?:>\s)*>\s)', line) if m: prefix += m.group(1) - m = re.match('^(>[>\s]*)', line[len(prefix):]) + m = re.match(r'^(>[>\s]*)', line[len(prefix):]) if m: prefix += m.group(1) quote_prefix += prefix @@ -896,19 +896,19 @@ def heading_replace(match): # adjust badly indented codeblocks if in_td: if line.strip(): - indent = re.search('[^\s]', line).start() + indent = re.search(r'[^\s]', line).start() if indent < in_td_prefix: in_td_defect = max(in_td_defect, in_td_prefix - indent) in_td_n += 1 if in_html: if line.strip(): - indent = re.search('[^\s]', line).start() + indent = re.search(r'[^\s]', line).start() if indent < in_html_prefix: in_html_defect = max(in_html_defect, in_html_prefix - indent) in_html_n += 1 if in_code: if line.strip(): - indent = re.search('[^\s]', line).start() + indent = re.search(r'[^\s]', line).start() if indent < in_code_prefix: in_code_defect = max(in_code_defect, in_code_prefix - indent) in_code_n += 1 @@ -1077,12 +1077,12 @@ def heading_replace(match): # lists if in_list: if line.strip(): - indent = re.search('[^\s]', line).start() + indent = re.search(r'[^\s]', line).start() if indent > list_leading_spaces: line = line[list_leading_spaces:] # adjust slightly-malformed paragraph in list for right indent -- fingers crossed - indent = re.search('[^\s]', line).start() + indent = re.search(r'[^\s]', line).start() if indent == 1 and list_indents[0][1] == '*': line = ' ' + line elif indent == 1 and list_indents[0][1] == '-': @@ -1095,18 +1095,18 @@ def heading_replace(match): list_indents = [] elif indent == list_leading_spaces: l = line[indent:] - if not (l.startswith('* ') or l.startswith('- ') or re.match('^[^\s]+\.\s', l)): + if not (l.startswith('* ') or l.startswith('- ') or re.match(r'^[^\s]+\.\s', l)): in_list = False list_indents = [] else: line = line[list_leading_spaces:] l = line.lstrip() - if l.startswith('* ') or l.startswith('- ') or re.match('^[^\s]+\.\s', l): + if l.startswith('* ') or l.startswith('- ') or re.match(r'^[^\s]+\.\s', l): if not in_list: - list_leading_spaces = re.search('[^\s]', line).start() + list_leading_spaces = re.search(r'[^\s]', line).start() line = line[list_leading_spaces:] in_list = True - indent = re.search('[^\s]', line).start() + indent = re.search(r'[^\s]', line).start() for i in range(len(list_indents)): d, t, c = list_indents[i] if indent == d: