Skip to content

Commit 418ad4d

Browse files
committed
Annotate type of main function, refactor for mypy, rename fatal_warnings variable
1 parent f2cd73c commit 418ad4d

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Doc/tools/check-epub.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@
22
from pathlib import Path
33

44

5-
def main():
5+
def main() -> int:
66
wrong_directory_msg = "Must run this script from the repo root"
77
if not Path("Doc").exists() or not Path("Doc").is_dir():
88
raise RuntimeError(wrong_directory_msg)
99

1010
with Path("Doc/epubcheck.txt").open(encoding="UTF-8") as f:
11-
warnings = f.read().splitlines()
11+
warnings = [warning.split(" - ") for warning in f.read().splitlines()]
1212

13-
warnings = [warning.split(" - ") for warning in warnings]
13+
fatal_warnings = [warning for warning in warnings if warning[0] == "FATAL"]
1414

15-
fatals = [warning for warning in warnings if warning[0] == "FATAL"]
16-
17-
if fatals:
15+
if fatal_warnings:
1816
print("\nError: must not contain fatal errors:\n")
19-
for fatal in fatals:
20-
print(" - ".join(fatal))
17+
for warning in fatal_warnings:
18+
print(" - ".join(warning))
2119

22-
return len(fatals)
20+
return len(fatal_warnings)
2321

2422

2523
if __name__ == "__main__":

0 commit comments

Comments
 (0)