Skip to content

Commit c21eb36

Browse files
committed
dev: Raise a nice error when we can't find guards in refactor_headers.py
1 parent 42ef2ad commit c21eb36

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

development/scripts/misc/refactor_headers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,12 @@ def update_content(
284284
with path.open() as path_desc:
285285
content = path_desc.read()
286286
old_guard = find_guard(content)
287+
if old_guard is None:
288+
raise RuntimeError(f"{path} doesn't contains valid guards")
287289
print(f"\tNew guard: {new_guard}")
288290
content = update_guard(content, old_guard, new_guard)
291+
if content is None:
292+
raise RuntimeError(f"{path} doesn't have three guards")
289293
content, includes = remove_includes(content, str(module_path))
290294
if not dry:
291295
with path.open("w") as path:
@@ -389,6 +393,7 @@ def update_module(module_path: Path, include_root_path: Path, dry: bool = False)
389393
if not dry:
390394
with module_path.open("w") as module_path_desc:
391395
module_path_desc.write(module_content)
396+
print()
392397

393398

394399
def is_dir(dir: str) -> Path:

0 commit comments

Comments
 (0)