Skip to content

Commit

Permalink
throw an actual error please
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Sep 22, 2023
1 parent 678511c commit cc21b3f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scripts/zombie_todos.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ async def fetch_issues():
internal_issue_number_pattern = re.compile(r"TODO\((?:#(\d+))(?:,\s*(?:#(\d+)))*\)")


def check_file(path: str) -> None:
# Returns true if the file is OK.
def check_file(path: str) -> bool:
ok = True
closed_issues = set(issues)
with open(path) as f:
for i, line in enumerate(f.readlines()):
Expand All @@ -83,6 +85,8 @@ def check_file(path: str) -> None:
for match in matches.groups():
if match is not None and int(match) in closed_issues:
print(f"{path}+{i}: {line.strip()}")
ok &= False
return ok


# ---
Expand All @@ -105,6 +109,7 @@ def main() -> None:

should_ignore = parse_gitignore(".gitignore") # TODO(emilk): parse all .gitignore files, not just top-level

ok = True
for root, dirs, files in os.walk(".", topdown=True):
dirs[:] = [d for d in dirs if not should_ignore(d)]

Expand All @@ -115,7 +120,10 @@ def main() -> None:
if should_ignore(filepath):
continue
if filepath not in exclude_paths:
check_file(filepath)
ok &= check_file(filepath)

if not ok:
raise ValueError("Clean your zombies!")


if __name__ == "__main__":
Expand Down

0 comments on commit cc21b3f

Please sign in to comment.