Skip to content

Commit

Permalink
ignores {N} during regex f-string sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom O'Hara committed Oct 8, 2023
1 parent 692eb35 commit 5740d03
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mezcla/my_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ def check_pattern(self, regex):
Note: Added to account for potential f-string confusion"""
# TODO: Add way to disable check
debug.reference_var(self)
check_regex = r"[^{]\{[A-Fa-f0-9][^{}]+\}[^}]"
check_regex = r"[^{]\{[^0-9][A-Fa-f0-9]*[^{}]+\}[^}]"
if isinstance(regex, bytes):
check_regex = check_regex.encode()
if (debug.debugging(1) and re.search(check_regex, regex)):
system.print_error(f"Warning: potentially unresolved f-string in {regex}")
if debug.debugging(1):
match = re.search(check_regex, regex)
if match:
system.print_error(f"Warning: potentially unresolved f-string in {regex} at {match.start(0)}")

def search(self, regex, text, flags=0, base_trace_level=None):
"""Search for REGEX in TEXT with optional FLAGS and BASE_TRACE_LEVEL (e.g., 6)"""
Expand Down

0 comments on commit 5740d03

Please sign in to comment.