From 39a79b53035d02317203c55394619611b6f25480 Mon Sep 17 00:00:00 2001 From: i331795 Date: Thu, 7 May 2026 08:58:01 +0530 Subject: [PATCH] Fix SyntaxWarning for invalid escape sequences in Python 3.12 Python 3.12 raises SyntaxWarning for invalid escape sequences in regular strings. Convert regex patterns to raw strings (r'...') and escape backslashes in docstring to suppress these warnings. --- watcher/common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/watcher/common.py b/watcher/common.py index 6ec69d7..cd4fac4 100644 --- a/watcher/common.py +++ b/watcher/common.py @@ -20,8 +20,8 @@ UID_REGEX = '[a-fA-F0-9-?]{32,36}' -VERSION_REGEX = '^v(?:\d+\.)?(?:\d+\.)?(\*|\d+)$' -TIMESTAMP_REGEX = '^\d{4}-\d{2}-\d{2}$' +VERSION_REGEX = r'^v(?:\d+\.)?(?:\d+\.)?(\*|\d+)$' +TIMESTAMP_REGEX = r'^\d{4}-\d{2}-\d{2}$' METHOD_ACTION_MAP = { 'GET': taxonomy.ACTION_READ, @@ -145,7 +145,7 @@ def get_project_id_from_os_path(path): """ get the project uid from a path if there's one path must be something like ..///.. - version must follow regex: '^v(?:\d+\.)?(?:\d+\.)?(\*|\d+)$' + version must follow regex: '^v(?:\\d+\\.)?(?:\\d+\\.)?(\\*|\\d+)$' (v1,v1.0,..) :param path: path containing a project uid @@ -231,7 +231,7 @@ def endswith_version(string): :param string: the string to check :return: bool whether the string ends with a version """ - version_ending_pattern = re.compile('\S*v(?:\d+\.)?(?:\d+\.)?(\*|\d+)$') + version_ending_pattern = re.compile(r'\S*v(?:\d+\.)?(?:\d+\.)?(\*|\d+)$') if version_ending_pattern.match(string.rstrip('/')): return True return False