Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ with the exception that minor releases may include breaking changes.

## [Unreleased]

## [1.3.1] - 2026-06-17

### Fixed

- 🐛 Run `prek` from root of target repository ([#344]) ([**@denialhaag**])

## [1.3.0] - 2026-06-16

_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md#130)._
Expand Down Expand Up @@ -224,7 +230,8 @@ _If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md#110)._

<!-- Version links -->

[unreleased]: https://github.com/munich-quantum-toolkit/templates/compare/v1.3.0...HEAD
[unreleased]: https://github.com/munich-quantum-toolkit/templates/compare/v1.3.1...HEAD
[1.3.1]: https://github.com/munich-quantum-toolkit/templates/releases/tag/v1.3.1
[1.3.0]: https://github.com/munich-quantum-toolkit/templates/releases/tag/v1.3.0
[1.2.0]: https://github.com/munich-quantum-toolkit/templates/releases/tag/v1.2.0
[1.1.13]: https://github.com/munich-quantum-toolkit/templates/releases/tag/v1.1.13
Expand All @@ -245,6 +252,7 @@ _If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md#110)._

<!-- PR links -->

[#344]: https://github.com/munich-quantum-toolkit/templates/pull/344
[#338]: https://github.com/munich-quantum-toolkit/templates/pull/338
[#332]: https://github.com/munich-quantum-toolkit/templates/pull/332
[#328]: https://github.com/munich-quantum-toolkit/templates/pull/328
Expand Down
10 changes: 6 additions & 4 deletions src/mqt/templates/render_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def render_templates(
Raises:
ValueError: If the arguments are incompatible with each other or if the project type is not supported.
"""
target_dir = target_dir.resolve()

supported_project_types = ["pure-python", "c++-python", "c++-mlir-python", "other"]
if project_type not in supported_project_types:
msg = f"Project type '{project_type}' is not supported. Must be one of {supported_project_types}."
Expand Down Expand Up @@ -236,7 +238,7 @@ def render_templates(
if template_container.arguments is None:
_copy_template(template_container, output_dir)
else:
_render_template(environment, template_container, output_dir)
_render_template(environment, template_container, target_dir)


def _copy_template(template_container: TemplateContainer, output_dir: Path) -> None:
Expand All @@ -252,7 +254,7 @@ def _copy_template(template_container: TemplateContainer, output_dir: Path) -> N
output_path.write_text(output, encoding="utf-8")


def _render_template(environment: jinja2.Environment, template_container: TemplateContainer, output_dir: Path) -> None:
def _render_template(environment: jinja2.Environment, template_container: TemplateContainer, target_dir: Path) -> None:
"""Render a template."""
if template_container.active:
assert template_container.arguments is not None
Expand All @@ -263,8 +265,8 @@ def _render_template(environment: jinja2.Environment, template_container: Templa
output = template.render(**template_container.arguments)

# Write the rendered template to a file
output_path = output_dir / template_container.file_name
output_path = target_dir / template_container.output_dir / template_container.file_name
output_path.write_text(output + "\n", encoding="utf-8")

# Format the rendered template
subprocess.run(["prek", "run", "--files", str(output_path)], check=False)
subprocess.run(["prek", "run", "--files", str(output_path)], cwd=target_dir, check=False)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Loading