Skip to content

Commit

Permalink
Fix line length linter
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
DimitriPapadopoulos committed Nov 5, 2023
1 parent 4ae6e53 commit b0fdb30
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/lint/line_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down

0 comments on commit b0fdb30

Please sign in to comment.