Skip to content

🐛 Run prek from root of target repository#344

Merged
denialhaag merged 3 commits into
mainfrom
run-prek-from-cwd
Jun 17, 2026
Merged

🐛 Run prek from root of target repository#344
denialhaag merged 3 commits into
mainfrom
run-prek-from-cwd

Conversation

@denialhaag

@denialhaag denialhaag commented Jun 17, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes a bug encountered in munich-quantum-toolkit/core#1790. Because prek is not running from the current directory, it cannot find the pre-commit and rumdl configurations in the target repository. This PR fixes this by setting the cwd argument of subprocess.run.

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

@denialhaag denialhaag self-assigned this Jun 17, 2026
@denialhaag denialhaag added the fix Fixes something that is not working label Jun 17, 2026
@denialhaag denialhaag changed the title 🐛 Run prek from current working direcory 🐛 Run prek from root of target repository Jun 17, 2026
@denialhaag denialhaag marked this pull request as ready for review June 17, 2026 13:59
@denialhaag

Copy link
Copy Markdown
Member Author

Successfully tested in munich-quantum-toolkit/core#1792. git --no-pager diff is empty.

@denialhaag

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@denialhaag, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 45 minutes and 50 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9e944723-d7c5-4cda-ab5d-0b7563bef502

📥 Commits

Reviewing files that changed from the base of the PR and between 50535d8 and 422ffcd.

📒 Files selected for processing (1)
  • src/mqt/templates/render_templates.py
📝 Walkthrough

Walkthrough

_render_template is updated to accept target_dir instead of a pre-computed output_dir. It now constructs the output file path internally from target_dir and runs the prek run formatting subprocess with cwd=target_dir. CHANGELOG.md records this as the 1.3.1 release.

Changes

prek working directory fix

Layer / File(s) Summary
_render_template signature and cwd fix
src/mqt/templates/render_templates.py
render_templates now passes target_dir to _render_template instead of a pre-computed output_dir. _render_template's signature changes from output_dir to target_dir, and the output path is rebuilt as target_dir / template_container.output_dir / template_container.file_name. The prek run subprocess is invoked with cwd=target_dir.
CHANGELOG 1.3.1 release entry
CHANGELOG.md
A new 1.3.1 release section with a "Fixed" entry for the prek working-directory change is added; the [unreleased] compare link and [1.3.1] release tag link are updated; PR #344 is appended to the reference list.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • munich-quantum-toolkit/templates#338: Directly modifies the same render_templates.py file to introduce prek run invocation on rendered template files, which is the same code path this PR fixes.

Poem

🐇 Hop, hop, said the rabbit with glee,
Now prek runs where the target should be!
No more lost in a faraway dir,
The right cwd brings us back to what's clear.
The changelog is stamped: 1.3.1—hooray!
Fixed and released on this fine summer day! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: running prek from the root of the target repository, which directly corresponds to the core change in the PR.
Description check ✅ Passed The description includes a clear summary of the bug fix with context, references the related issue, completes the relevant checklist items, and provides sufficient information about the change and its rationale.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch run-prek-from-cwd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/mqt/templates/render_templates.py`:
- Around line 266-270: The subprocess.run call for prek is passing the full
output_path (which already includes target_dir) while also setting
cwd=target_dir, causing prek to receive a doubly-prefixed path when target_dir
is relative. Fix this by computing the relative path of output_path from
target_dir and passing that relative path to the prek subprocess instead of
passing str(output_path). Use output_path.relative_to(target_dir) to get the
correct relative path argument to pass to the --files option.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 33f00095-6fe0-40fa-809b-e3b79fddc24e

📥 Commits

Reviewing files that changed from the base of the PR and between a76c310 and 50535d8.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • src/mqt/templates/render_templates.py

Comment thread src/mqt/templates/render_templates.py
@denialhaag denialhaag requested a review from burgholzer June 17, 2026 14:14
@denialhaag

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@denialhaag denialhaag merged commit 7fe3464 into main Jun 17, 2026
9 checks passed
@denialhaag denialhaag deleted the run-prek-from-cwd branch June 17, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fixes something that is not working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants