Skip to content

Commit e67ba23

Browse files
committed
refactor(check): type CheckArgs arguments
1 parent 0493765 commit e67ba23

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

commitizen/commands/check.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import re
44
import sys
5-
from typing import Any
5+
from typing import TypedDict
66

77
from commitizen import factory, git, out
88
from commitizen.config import BaseConfig
@@ -13,27 +13,36 @@
1313
)
1414

1515

16+
class CheckArgs(TypedDict, total=False):
17+
commit_msg_file: str
18+
commit_msg: str
19+
rev_range: str
20+
allow_abort: bool
21+
message_length_limit: int
22+
allowed_prefixes: list[str]
23+
message: str
24+
25+
1626
class Check:
1727
"""Check if the current commit msg matches the commitizen format."""
1828

19-
def __init__(self, config: BaseConfig, arguments: dict[str, Any]) -> None:
29+
def __init__(self, config: BaseConfig, arguments: CheckArgs) -> None:
2030
"""Initial check command.
2131
2232
Args:
2333
config: The config object required for the command to perform its action
2434
arguments: All the flags provided by the user
2535
cwd: Current work directory
2636
"""
27-
self.commit_msg_file: str | None = arguments.get("commit_msg_file")
28-
self.commit_msg: str | None = arguments.get("message")
29-
self.rev_range: str | None = arguments.get("rev_range")
30-
self.allow_abort: bool = bool(
37+
self.commit_msg_file = arguments.get("commit_msg_file")
38+
self.commit_msg = arguments.get("message")
39+
self.rev_range = arguments.get("rev_range")
40+
self.allow_abort = bool(
3141
arguments.get("allow_abort", config.settings["allow_abort"])
3242
)
33-
self.max_msg_length: int = arguments.get("message_length_limit", 0)
43+
self.max_msg_length = arguments.get("message_length_limit", 0)
3444

3545
# we need to distinguish between None and [], which is a valid value
36-
3746
allowed_prefixes = arguments.get("allowed_prefixes")
3847
self.allowed_prefixes: list[str] = (
3948
allowed_prefixes

0 commit comments

Comments
 (0)