Skip to content

Commit 888606b

Browse files
committed
style: refine coding style based on reviews
1 parent 506ca59 commit 888606b

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

commitizen/commands/commit.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
from __future__ import annotations
2+
13
import contextlib
24
import os
35

4-
from typing import Optional
56

67
import questionary
78

@@ -35,7 +36,7 @@ def __init__(self, config: BaseConfig, arguments: dict):
3536
self.arguments = arguments
3637
self.temp_file: str = get_backup_file_path()
3738

38-
def read_backup_message(self) -> Optional[str]:
39+
def read_backup_message(self) -> str | None:
3940
# Check the commit backup file exists
4041
if not os.path.isfile(self.temp_file):
4142
return None

commitizen/cz/utils.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,5 @@ def get_backup_file_path() -> str:
2828
else:
2929
project = project_root.as_posix().replace("/", "%")
3030

31-
return os.path.join(
32-
tempfile.gettempdir(),
33-
"cz.commit%{user}%{project}.backup".format(
34-
user=os.environ.get("USER", ""),
35-
project=project,
36-
),
37-
)
31+
user = os.environ.get("USER", "")
32+
return os.path.join(tempfile.gettempdir(), f"cz.commit%{user}%{project}.backup")

hooks/post-commit.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
try:
55
from commitizen.cz.utils import get_backup_file_path
66
except ImportError as error:
7-
print("could not import commitizen:")
8-
print(error)
7+
print(f"could not import commitizen:\n{error}")
98
exit(1)
109

1110

0 commit comments

Comments
 (0)