Skip to content

Commit

Permalink
chore: fix SyntaxWarning: invalid escape sequence + for py3.12
Browse files Browse the repository at this point in the history
```
/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 Homebrew/homebrew-core#157669

cc @cushon

Fixes #1017

COPYBARA_INTEGRATE_REVIEW=#1017 from chenrui333:py3.12 36d80d1
PiperOrigin-RevId: 592246854
  • Loading branch information
chenrui333 authored and google-java-format Team committed Dec 19, 2023
1 parent 0e7cc6f commit 627c97e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/google-java-format-diff.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 627c97e

Please sign in to comment.