From d37a54373db7340906728a327318ebdf714af088 Mon Sep 17 00:00:00 2001 From: Matt Frank Date: Fri, 29 May 2026 10:37:14 -0500 Subject: [PATCH] Fix SyntaxWarning from invalid escape sequences in regex patterns Use raw strings for regex patterns in mlp_compliance.py and ruleset_060.py so that \w, \d, \s, and \. are not parsed as Python string escapes. The resulting strings are identical, so matching behavior is unchanged; this only silences the SyntaxWarning emitted by modern Python. Co-Authored-By: Claude Opus 4.7 --- mlperf_logging/compliance_checker/mlp_compliance.py | 4 ++-- mlperf_logging/compliance_checker/mlp_parser/ruleset_060.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mlperf_logging/compliance_checker/mlp_compliance.py b/mlperf_logging/compliance_checker/mlp_compliance.py index e7ee391c..42b12f95 100644 --- a/mlperf_logging/compliance_checker/mlp_compliance.py +++ b/mlperf_logging/compliance_checker/mlp_compliance.py @@ -304,11 +304,11 @@ def check_file(self, filename, config_file): def usage_choices(): return set(( x.split("_")[0] for x in os.listdir(os.path.dirname(__file__)) - if re.match('\w+_\d+\.\d+\.\d+', x) )) + if re.match(r'\w+_\d+\.\d+\.\d+', x) )) def rule_choices(): return set(( x.split("_")[1] for x in os.listdir(os.path.dirname(__file__)) - if re.match('\w+_\d+\.\d+\.\d+', x) )) + if re.match(r'\w+_\d+\.\d+\.\d+', x) )) def get_parser(): diff --git a/mlperf_logging/compliance_checker/mlp_parser/ruleset_060.py b/mlperf_logging/compliance_checker/mlp_parser/ruleset_060.py index e5f8da56..95ebdba1 100644 --- a/mlperf_logging/compliance_checker/mlp_parser/ruleset_060.py +++ b/mlperf_logging/compliance_checker/mlp_parser/ruleset_060.py @@ -23,7 +23,7 @@ TOKEN = ':::MLL' # ^.* -LINE_PATTERN = '^' + TOKEN + ''' [ ] # token and version +LINE_PATTERN = '^' + TOKEN + r''' [ ] # token and version ([\d\.]+) [ ] # timestamp ([A-Za-z0-9_]+) [ ]? # key :\s+(.+) # value