Skip to content

Commit 21f4483

Browse files
committed
Use 'in' instead of 'find()' in tidy.py
'x in y' is more Pythonic and faster than 'y.find(x) != -1'.
1 parent dcaeb6a commit 21f4483

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/etc/tidy.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ def do_license_check(name, contents):
5858
for line in fileinput.input(file_names,
5959
openhook=fileinput.hook_encoded("utf-8")):
6060

61-
if fileinput.filename().find("tidy.py") == -1:
62-
if line.find(cr_flag) != -1:
61+
if "tidy.py" not in fileinput.filename():
62+
if cr_flag in line:
6363
check_cr = False
64-
if line.find(tab_flag) != -1:
64+
if tab_flag in line:
6565
check_tab = False
66-
if line.find(linelength_flag) != -1:
66+
if linelength_flag in line:
6767
check_linelength = False
68-
if line.find("TODO") != -1:
68+
if "TODO" in line:
6969
report_err("TODO is deprecated; use FIXME")
7070
match = re.match(r'^.*/(\*|/!?)\s*XXX', line)
7171
if match:
@@ -86,10 +86,10 @@ def do_license_check(name, contents):
8686
if "SNAP" in line:
8787
report_warn("unmatched SNAP line: " + line)
8888

89-
if check_tab and (line.find('\t') != -1 and
90-
fileinput.filename().find("Makefile") == -1):
89+
if check_tab and ('\t' in line and
90+
"Makefile" not in fileinput.filename()):
9191
report_err("tab character")
92-
if check_cr and not autocrlf and line.find('\r') != -1:
92+
if check_cr and not autocrlf and '\r' in line:
9393
report_err("CR character")
9494
if line.endswith(" \n") or line.endswith("\t\n"):
9595
report_err("trailing whitespace")

0 commit comments

Comments
 (0)