From 45a7acb9593c927511d03dd103e68ec10b221fda Mon Sep 17 00:00:00 2001 From: tritao Date: Fri, 9 May 2025 23:50:05 +0100 Subject: [PATCH] Fix regressions in CI linting generic checks. This got broken due to applying some review suggestions without proper testing. This fixes commit 5e72c0afe508a698cadb209af190102b12774005. Closes https://github.com/FreeCAD/FreeCAD/issues/21231. --- tools/lint/generic_checks.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/lint/generic_checks.py b/tools/lint/generic_checks.py index b7eb19675f..74cc197cee 100755 --- a/tools/lint/generic_checks.py +++ b/tools/lint/generic_checks.py @@ -35,8 +35,12 @@ def check_trailing_whitespace(file_paths): for path in file_paths: try: with open(path, "r", encoding="utf-8") as f: - lines = files.read().splitlines() - error_lines = [idx if line.endswith(" ") for idx, line in enumerate(lines, start=1)] + lines = f.read().splitlines() + error_lines = [ + idx + for idx, line in enumerate(lines, start=1) + if line != line.rstrip() + ] if error_lines: issues[path] = error_lines except Exception as e: @@ -53,8 +57,10 @@ def check_tabs(file_paths): for path in file_paths: try: with open(path, "r", encoding="utf-8") as f: - lines = f.readlines() - tab_lines = [idx if "\t" in line for idx, line in enumerate(lines, start=1)] + lines = f.read().splitlines() + tab_lines = [ + idx for idx, line in enumerate(lines, start=1) if "\t" in line + ] if tab_lines: issues[path] = tab_lines except Exception as e: