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 80f2812

Browse files
bearomorphismLee-W
authored andcommitted
refactor(Init): fix unbounded variable in _ask_tag_format
1 parent f92357a commit 80f2812

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

‎commitizen/commands/init.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -210,23 +210,20 @@ def _ask_tag(self) -> str:
210210
return latest_tag
211211

212212
def _ask_tag_format(self, latest_tag: str) -> str:
213-
is_correct_format = False
214213
if latest_tag.startswith("v"):
215-
tag_format = r"v$version"
216-
is_correct_format = questionary.confirm(
217-
f'Is "{tag_format}" the correct tag format?', style=self.cz.style
218-
).unsafe_ask()
214+
v_tag_format = r"v$version"
215+
if questionary.confirm(
216+
f'Is "{v_tag_format}" the correct tag format?', style=self.cz.style
217+
).unsafe_ask():
218+
return v_tag_format
219219

220220
default_format = DEFAULT_SETTINGS["tag_format"]
221-
if not is_correct_format:
222-
tag_format = questionary.text(
223-
f'Please enter the correct version format: (default: "{default_format}")',
224-
style=self.cz.style,
225-
).unsafe_ask()
221+
tag_format: str = questionary.text(
222+
f'Please enter the correct version format: (default: "{default_format}")',
223+
style=self.cz.style,
224+
).unsafe_ask()
226225

227-
if not tag_format:
228-
tag_format = default_format
229-
return tag_format
226+
return tag_format or default_format
230227

231228
def _ask_version_provider(self) -> str:
232229
"""Ask for setting: version_provider"""

0 commit comments

Comments
(0)

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