Skip to content

Commit 326c540

Browse files
makotokatojonalmeida
authored andcommitted
Use raw syntax to avoid SyntaxWarning.
1 parent d33fd96 commit 326c540

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

apilint/src/main/resources/apilint.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __init__(self, clazz, location, raw, blame, imports):
120120
self.blame = blame
121121
self.source = None
122122

123-
raw = collect_chunks(raw, "[\s;]")
123+
raw = collect_chunks(raw, r"[\s;]")
124124
self.split = list(raw)
125125

126126
for r in ["field", "enum_constant", "volatile", "transient", "public", "protected", "static", "final", "deprecated"]:
@@ -149,7 +149,7 @@ def __repr__(self):
149149

150150
class Argument():
151151
def __init__(self, clazz, source, raw, location, blame, imports):
152-
raw = collect_chunks(raw, "\s")
152+
raw = collect_chunks(raw, r"\s")
153153
self.annotations = [
154154
Annotation(clazz, self, location, a, blame, imports) for a in raw if a.startswith("@")]
155155
raw = [x for x in raw if not x.startswith("@")]
@@ -210,7 +210,7 @@ def __init__(self, clazz, location, raw, blame, imports):
210210
self.blame = blame
211211
self.source = None
212212

213-
raw = collect_chunks(raw, "\s")
213+
raw = collect_chunks(raw, r"\s")
214214

215215
for r in ["", ";"]:
216216
while r in raw: raw.remove(r)
@@ -332,7 +332,7 @@ def __init__(self, pkg, location, raw, blame, imports):
332332
self.methods = []
333333
self.source = None
334334

335-
raw = collect_chunks(self.raw, "\s")
335+
raw = collect_chunks(self.raw, r"\s")
336336
self.split = list(raw)
337337
self.isEnum = False
338338
if "class" in raw:
@@ -348,7 +348,7 @@ def __init__(self, pkg, location, raw, blame, imports):
348348
if "extends" in raw:
349349
self.extends = Type(self, None, raw[raw.index("extends")+1], location,
350350
blame, imports)
351-
self.extends_path = collect_chunks(self.extends.name, "\.")
351+
self.extends_path = collect_chunks(self.extends.name, r"\.")
352352
else:
353353
self.extends = None
354354
self.extends_path = []
@@ -403,7 +403,7 @@ def _parse_stream(f, api_map, clazz_cb=None):
403403
blame = None
404404
imports = {}
405405

406-
re_blame = re.compile("^([a-z0-9]{7,}) \(<([^>]+)>.+?\) (.+?)$")
406+
re_blame = re.compile(r"^([a-z0-9]{7,}) \(<([^>]+)>.+?\) (.+?)$")
407407
for raw in f:
408408
line += 1
409409
raw = raw.rstrip()
@@ -529,7 +529,7 @@ def notice(clazz):
529529

530530
def verify_constants(clazz):
531531
"""All static final constants must be FOO_NAME style."""
532-
if re.match("android\.R\.[a-z]+", clazz.fullname): return
532+
if re.match(r"android\.R\.[a-z]+", clazz.fullname): return
533533
if clazz.fullname.startswith("android.os.Build"): return
534534
if clazz.fullname == "android.system.OsConstants": return
535535

@@ -555,7 +555,7 @@ def verify_class_names(clazz):
555555
"""Try catching malformed class names like myMtp or MTPUser."""
556556
if clazz.fullname.startswith("android.opengl"): return
557557
if clazz.fullname.startswith("android.renderscript"): return
558-
if re.match("android\.R\.[a-z]+", clazz.fullname): return
558+
if re.match(r"android\.R\.[a-z]+", clazz.fullname): return
559559

560560
if re.search("[A-Z]{2,}", clazz.name) is not None:
561561
warn(clazz, None, "S1", "Class names with acronyms should be Mtp not MTP")
@@ -1314,7 +1314,7 @@ def verify_listener_last(clazz):
13141314

13151315
def verify_resource_names(clazz):
13161316
"""Verifies that resource names have consistent case."""
1317-
if not re.match("android\.R\.[a-z]+", clazz.fullname): return
1317+
if not re.match(r"android\.R\.[a-z]+", clazz.fullname): return
13181318

13191319
# Resources defined by files are foo_bar_baz
13201320
if clazz.name in ["anim","animator","color","dimen","drawable","interpolator","layout","transition","menu","mipmap","string","plurals","raw","xml"]:
@@ -1374,7 +1374,7 @@ def verify_manager_list(clazz):
13741374
def verify_abstract_inner(clazz):
13751375
"""Verifies that abstract inner classes are static."""
13761376

1377-
if re.match(".+?\.[A-Z][^\.]+\.[A-Z]", clazz.fullname):
1377+
if re.match(r".+?\.[A-Z][^\.]+\.[A-Z]", clazz.fullname):
13781378
if " abstract " in clazz.raw and " static " not in clazz.raw:
13791379
warn(clazz, None, None, "Abstract inner classes should be static to improve testability")
13801380

apilint/src/main/resources/changelog-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import re
1111
import sys
1212

13-
API_VERSION_REGEX = re.compile('^\[api-version\]: ([a-f0-9]{40})$')
13+
API_VERSION_REGEX = re.compile(r'^\[api-version\]: ([a-f0-9]{40})$')
1414

1515
class MissingApiVersionError(Exception):
1616
pass

0 commit comments

Comments
 (0)