Skip to content

Commit fe13eba

Browse files
committed
style(hooks): improve type annotation
1 parent d4dfd33 commit fe13eba

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

hooks/post-commit.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
exit(1)
99

1010

11-
def post_commit():
11+
def post_commit() -> None:
1212
backup_file = Path(get_backup_file_path())
1313

1414
# remove backup file if it exists
@@ -17,4 +17,5 @@ def post_commit():
1717

1818

1919
if __name__ == "__main__":
20-
exit(post_commit())
20+
post_commit()
21+
exit(0)

hooks/prepare-commit-msg.py

+12-14
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,19 @@
1313
exit(1)
1414

1515

16-
def prepare_commit_msg(commit_msg_file: Path) -> int:
16+
def prepare_commit_msg(commit_msg_file: str) -> int:
1717
# check if the commit message needs to be generated using commitizen
18-
if (
19-
subprocess.run(
20-
[
21-
"cz",
22-
"check",
23-
"--commit-msg-file",
24-
commit_msg_file,
25-
],
26-
capture_output=True,
27-
).returncode
28-
!= 0
29-
):
18+
exit_code = subprocess.run(
19+
[
20+
"cz",
21+
"check",
22+
"--commit-msg-file",
23+
commit_msg_file,
24+
],
25+
capture_output=True,
26+
).returncode
27+
if exit_code != 0:
3028
backup_file = Path(get_backup_file_path())
31-
3229
if backup_file.is_file():
3330
# confirm if commit message from backup file should be reused
3431
answer = input("retry with previous message? [y/N]: ")
@@ -54,6 +51,7 @@ def prepare_commit_msg(commit_msg_file: Path) -> int:
5451

5552
# write message to backup file
5653
shutil.copyfile(commit_msg_file, backup_file)
54+
return 0
5755

5856

5957
if __name__ == "__main__":

0 commit comments

Comments
 (0)