Skip to content

Commit 6f9a3d2

Browse files
committed
refactor(Init): fix unbounded variable in _ask_tag_format
1 parent 6b4f8b0 commit 6f9a3d2

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
@@ -208,23 +208,20 @@ def _ask_tag(self) -> str:
208208
return latest_tag
209209

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

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

225-
if not tag_format:
226-
tag_format = default_format
227-
return tag_format
224+
return tag_format or default_format
228225

229226
def _ask_version_provider(self) -> str:
230227
"""Ask for setting: version_provider"""

0 commit comments

Comments
 (0)