Skip to content

Commit 148fe46

Browse files
author
Colin Leong
committed
CDL: actually fix return value
1 parent 2675b7e commit 148fe46

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/find_bare_citations.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,24 @@ def find_bare_citations(markdown_file_path:Path, citation_keys:list)->list:
7171
start_time = timeit.default_timer()
7272
issues = find_bare_citations(args.markdown_file_path, citation_keys)
7373

74-
if issues:
75-
print("Found the following lines with bare citations:")
76-
print()
7774

78-
for citation_key, matches in issues:
79-
print(f"Citation key: {citation_key}")
75+
print("Found the following lines with bare citations:")
76+
print()
77+
78+
# we cannot simply check "if issues" due to using yield
79+
issues_exist = False
80+
for citation_key, matches in issues:
81+
print(f"Citation key: {citation_key}")
8082

81-
for match in matches:
82-
print(f"* {match.group(0)}")
83-
print()
83+
for match in matches:
84+
print(f"* {match.group(0)}")
85+
86+
# iff we've gotten here then issues exist and we should set return value to 1 at the end.
87+
issues_exist = True
88+
print()
8489
elapsed_time = timeit.default_timer() - start_time
8590
print(f"Bare-citation check complete after ~{elapsed_time:.2f} seconds")
86-
if issues:
91+
if issues_exist:
8792
sys.exit(1) # exit with an error
8893

8994

0 commit comments

Comments
 (0)