Skip to content

Commit

Permalink
style: refine coding style based on reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-W committed Mar 30, 2024
1 parent fc3c1e9 commit b42a676
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
5 changes: 3 additions & 2 deletions commitizen/commands/commit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

import contextlib
import os

from typing import Optional

import questionary

Expand Down Expand Up @@ -35,7 +36,7 @@ def __init__(self, config: BaseConfig, arguments: dict):
self.arguments = arguments
self.temp_file: str = get_backup_file_path()

def read_backup_message(self) -> Optional[str]:
def read_backup_message(self) -> str | None:
# Check the commit backup file exists
if not os.path.isfile(self.temp_file):
return None
Expand Down
9 changes: 2 additions & 7 deletions commitizen/cz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,5 @@ def get_backup_file_path() -> str:
else:
project = project_root.as_posix().replace("/", "%")

return os.path.join(
tempfile.gettempdir(),
"cz.commit%{user}%{project}.backup".format(
user=os.environ.get("USER", ""),
project=project,
),
)
user = os.environ.get("USER", "")
return os.path.join(tempfile.gettempdir(), f"cz.commit%{user}%{project}.backup")
3 changes: 1 addition & 2 deletions hooks/post-commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
try:
from commitizen.cz.utils import get_backup_file_path
except ImportError as error:
print("could not import commitizen:")
print(error)
print(f"could not import commitizen:\n{error}")
exit(1)


Expand Down

0 comments on commit b42a676

Please sign in to comment.