Skip to content

Commit 5272fd2

Browse files
committed
fix(Changelog): fix _export_template variable type
Closes #1503
1 parent fb04e28 commit 5272fd2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

commitizen/commands/changelog.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,17 @@ def _write_changelog(
175175
changelog_file.write(changelog_out)
176176

177177
def _export_template(self) -> None:
178-
tpl = changelog.get_changelog_template(self.cz.template_loader, self.template)
179-
# TODO: fix the following type ignores
180-
src = Path(tpl.filename) # type: ignore[arg-type]
181-
Path(self.export_template_to).write_text(src.read_text()) # type: ignore[arg-type]
178+
if self.export_template_to is None:
179+
raise NotAllowed("Argument `--export-template` is not set")
180+
181+
filename = changelog.get_changelog_template(
182+
self.cz.template_loader, self.template
183+
).filename
184+
if filename is None:
185+
raise NotAllowed("Template filename is not set")
186+
187+
text = Path(filename).read_text()
188+
Path(self.export_template_to).write_text(text)
182189

183190
def __call__(self) -> None:
184191
commit_parser = self.cz.commit_parser

0 commit comments

Comments
 (0)