Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5a21f83

Browse files
bearomorphismLee-W
authored andcommitted
refactor(ParseArgs): simplify __call__ function body
1 parent 186dd18 commit 5a21f83

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)

AltStyle によって変換されたページ (->オリジナル) /