From 627c97e63c563ae04eca9aa1baeca99eac6c365a Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Tue, 19 Dec 2023 08:38:41 -0800 Subject: [PATCH] chore: fix `SyntaxWarning: invalid escape sequence +` for py3.12 ``` /opt/homebrew/Cellar/google-java-format/1.19.0/bin/google-java-format-diff:78: SyntaxWarning: invalid escape sequence '\+' match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line) /opt/homebrew/Cellar/google-java-format/1.19.0/bin/google-java-format-diff:91: SyntaxWarning: invalid escape sequence '\+' match = re.search('^@@.*\+(\d+)(,(\d+))?', line) ``` relates to https://github.com/Homebrew/homebrew-core/pull/157669 cc @cushon Fixes #1017 COPYBARA_INTEGRATE_REVIEW=https://github.com/google/google-java-format/pull/1017 from chenrui333:py3.12 36d80d13a9b76b11d0ffbafb0ab5d87e1101d5ba PiperOrigin-RevId: 592246854 --- scripts/google-java-format-diff.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/google-java-format-diff.py b/scripts/google-java-format-diff.py index 151ae33d9..2c75edac7 100755 --- a/scripts/google-java-format-diff.py +++ b/scripts/google-java-format-diff.py @@ -1,13 +1,13 @@ #!/usr/bin/env python3 # -#===- google-java-format-diff.py - google-java-format Diff Reformatter -----===# +# ===- google-java-format-diff.py - google-java-format Diff Reformatter -----===# # # The LLVM Compiler Infrastructure # # This file is distributed under the University of Illinois Open Source # License. See LICENSE.TXT for details. # -#===------------------------------------------------------------------------===# +# ===------------------------------------------------------------------------===# """ google-java-format Diff Reformatter @@ -75,7 +75,7 @@ def main(): lines_by_file = {} for line in sys.stdin: - match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line) + match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line) if match: filename = match.group(2) if filename == None: @@ -88,7 +88,7 @@ def main(): if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE): continue - match = re.search('^@@.*\+(\d+)(,(\d+))?', line) + match = re.search(r'^@@.*\+(\d+)(,(\d+))?', line) if match: start_line = int(match.group(1)) line_count = 1