From b0fdb30997eb1456942ef62c8a2cc512b0562957 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 5 Nov 2023 21:32:37 +0100 Subject: [PATCH] Fix line length linter * Write to sys.stderr in the hope the error message will show up in the CI job output. * Start enumerate at 1 instead of 0, to show the correct line number. --- tests/lint/line_length.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/lint/line_length.py b/tests/lint/line_length.py index 9266936f..9a696453 100755 --- a/tests/lint/line_length.py +++ b/tests/lint/line_length.py @@ -54,7 +54,7 @@ def main(): for arg in sys.argv[1:]: with open(arg, "r") as source_file: - for i, line in enumerate(source_file): + for i, line in enumerate(source_file, start=1): line = line.rstrip() # Lines that end with a string are exempted if endswithstring(line): @@ -63,7 +63,10 @@ def main(): line = line.replace("\t", " ") # Lines longer than MAX are reported as an error if len(line) > MAX: - print(f"{arg}: {i}: line too long ({len(line)} characters)") + print( + f"{arg}: {i}: line too long ({len(line)} characters)", + file=sys.stderr, + ) exit_status = 1 sys.exit(exit_status)