Skip to content

Commit baa0224

Browse files
committed
refactor(bump): eliminate similar patterns in code
1 parent baee83e commit baa0224

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

commitizen/commands/bump.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -382,16 +382,10 @@ def __call__(self) -> None: # noqa: C901
382382
err = c.err.strip() or c.out
383383
raise BumpCommitFailedError(f'2nd git.commit error: "{err}"')
384384

385-
if c.out:
386-
if self.git_output_to_stderr:
387-
out.diagnostic(c.out)
388-
else:
389-
out.write(c.out)
390-
if c.err:
391-
if self.git_output_to_stderr:
392-
out.diagnostic(c.err)
393-
else:
394-
out.write(c.err)
385+
for msg in (c.out, c.err):
386+
if msg:
387+
out_func = out.diagnostic if self.git_output_to_stderr else out.write
388+
out_func(msg)
395389

396390
c = git.tag(
397391
new_tag_version,

commitizen/config/json_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class JsonConfig(BaseConfig):
1313
def __init__(self, *, data: bytes | str, path: Path | str):
1414
super().__init__()
1515
self.is_empty_config = False
16-
self.path = path # type: ignore
16+
self.path = path
1717
self._parse_setting(data)
1818

1919
def init_empty_config_content(self):

commitizen/config/toml_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class TomlConfig(BaseConfig):
1414
def __init__(self, *, data: bytes | str, path: Path | str):
1515
super().__init__()
1616
self.is_empty_config = False
17-
self.path = path # type: ignore
17+
self.path = path
1818
self._parse_setting(data)
1919

2020
def init_empty_config_content(self):

commitizen/config/yaml_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class YAMLConfig(BaseConfig):
1414
def __init__(self, *, data: bytes | str, path: Path | str):
1515
super().__init__()
1616
self.is_empty_config = False
17-
self.path = path # type: ignore
17+
self.path = path
1818
self._parse_setting(data)
1919

2020
def init_empty_config_content(self):

0 commit comments

Comments
 (0)