diff --git a/tools/lint/generic_checks.py b/tools/lint/generic_checks.py index 25f1a2d794..b7eb19675f 100755 --- a/tools/lint/generic_checks.py +++ b/tools/lint/generic_checks.py @@ -35,11 +35,8 @@ def check_trailing_whitespace(file_paths): for path in file_paths: try: with open(path, "r", encoding="utf-8") as f: - lines = f.readlines() - error_lines = [] - for idx, line in enumerate(lines, start=1): - if line.rstrip("\n") != line.rstrip(): - error_lines.append(idx) + lines = files.read().splitlines() + error_lines = [idx if line.endswith(" ") for idx, line in enumerate(lines, start=1)] if error_lines: issues[path] = error_lines except Exception as e: @@ -57,10 +54,7 @@ def check_tabs(file_paths): try: with open(path, "r", encoding="utf-8") as f: lines = f.readlines() - tab_lines = [] - for idx, line in enumerate(lines, start=1): - if "\t" in line: - tab_lines.append(idx) + tab_lines = [idx if "\t" in line for idx, line in enumerate(lines, start=1)] if tab_lines: issues[path] = tab_lines except Exception as e: