From edaf50786346ed50b3c05fd30bfa1275c7cede4c Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 23 Jan 2025 15:52:03 +0100 Subject: [PATCH] [IMP] runbot_merge: make space characters in regexes clearer pycharm is a bit dumb so it considers `[ ]` to be unnecessary even in `re.VERBOSE` regexes. But it has a bit of a point in that it's not super clear, so inject the space characters by (unicode) name, the behaviour should be the exact same but the regexes should be slightly less opaque. --- runbot_merge/models/stagings_create.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runbot_merge/models/stagings_create.py b/runbot_merge/models/stagings_create.py index d68ef8b9..3fe33636 100644 --- a/runbot_merge/models/stagings_create.py +++ b/runbot_merge/models/stagings_create.py @@ -691,7 +691,7 @@ def add_self_references( )) BREAK = re.compile(r''' - [ ]{0,3} # 0-3 spaces of indentation + \N{SPACE}{0,3} # 0-3 spaces of indentation # followed by a sequence of three or more matching -, _, or * characters, # each followed optionally by any number of spaces or tabs # so needs to start with a _, - or *, then have at least 2 more such @@ -701,9 +701,9 @@ BREAK = re.compile(r''' [ \t]* ''', flags=re.VERBOSE) SETEX_UNDERLINE = re.compile(r''' - [ ]{0,3} # no more than 3 spaces indentation + \N{SPACE}{0,3} # no more than 3 spaces indentation [-=]+ # a sequence of = characters or a sequence of - characters - [ ]* # any number of trailing spaces + \N{SPACE}* # any number of trailing spaces # we don't care about "a line containing a single -" because we want to # disambiguate SETEX headings from thematic breaks, and thematic breaks have # 3+ -. Doesn't look like GH interprets `- - -` as a line so yay...