Skip to content

Commit 312ca49

Browse files
bearomorphismLee-W
authored andcommitted
refactor(ParseArgs): simplify __call__ function body
1 parent 6b4f8b0 commit 312ca49

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

commitizen/cli.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,13 @@ def __call__(
5252
) -> None:
5353
if not isinstance(values, str):
5454
return
55-
if "=" not in values:
55+
56+
key, sep, value = values.partition("=")
57+
if not key or not sep:
5658
raise InvalidCommandArgumentError(
5759
f"Option {option_string} expect a key=value format"
5860
)
5961
kwargs = getattr(namespace, self.dest, None) or {}
60-
key, value = values.split("=", 1)
61-
if not key:
62-
raise InvalidCommandArgumentError(
63-
f"Option {option_string} expect a key=value format"
64-
)
6562
kwargs[key] = value.strip("'\"")
6663
setattr(namespace, self.dest, kwargs)
6764

0 commit comments

Comments
 (0)