Skip to content

Add cargo-machete prek hook#165

Merged
david-pl merged 3 commits into
mainfrom
david/machete
Jun 30, 2026
Merged

Add cargo-machete prek hook#165
david-pl merged 3 commits into
mainfrom
david/machete

Conversation

@david-pl

Copy link
Copy Markdown
Collaborator

Adds cargo machete prek hook to detect unused dependency. This will run locally and as part of the CI. Also, removed some unused dependencies and pushed some (completely unrelated) python demo scripts I had lying around.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an unused-dependency check to the repo’s local/CI hook suite by introducing a cargo-machete prek hook (provisioned via mise), updates the developer guide to describe the new check, and prunes a few now-unused Rust dependencies. The PR also adds two Python demo scripts under ppvm-python/demo/.

Changes:

  • Add a workspace-wide cargo-machete hook to prek.toml and install the binary via mise.toml.
  • Document the new unused-dependency check in docs/src/pages/develop.astro.
  • Remove unused Rust dependencies from several manifests / lockfile; add Python demo scripts.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
prek.toml Adds a new local cargo-machete hook invoked via mise exec -- ….
mise.toml Adds cargo-machete to the mise-managed toolchain.
docs/src/pages/develop.astro Documents the new unused-dependency check and adds a code-style bullet.
ppvm-python/demo/squin_kernel.py Adds a squin-based demo using GeneralizedTableauSimulator.
ppvm-python/demo/hello_world.py Adds a demo that encodes/decodes “Hello, world!” via GeneralizedTableau.
crates/ppvm-tableau-sum/Cargo.toml Removes an unused crate dependency (ppvm-pauli-word).
crates/ppvm-python-native/Cargo.toml Removes an unused crate dependency (num).
Cargo.toml Removes unused top-level dependencies (fxhash, num).
Cargo.lock Updates lockfile to reflect removed dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread prek.toml
Comment on lines +62 to +63
pass_filenames = false
types = ["rust"]
Comment on lines +11 to +14
sim = GeneralizedTableauSimulator(2)
task = sim.task(main)
task.run()
print(task.state)
Comment on lines +10 to +32
MESSAGE = "Hello, world!"

# ASCII bytes -> bit list, MSB first within each byte.
data = MESSAGE.encode("ascii")
bits = [(byte >> (7 - i)) & 1 for byte in data for i in range(8)]

# One qubit per bit; flip every qubit whose target bit is 1.
tab = GeneralizedTableau(n_qubits=len(bits))
for q, bit in enumerate(bits):
if bit:
tab.x(q)

# Measure all qubits and decode the outcomes back into a string.
measured = [int(tab.measure(q)) for q in range(len(bits))]
decoded = bytes(
int("".join(str(b) for b in measured[i : i + 8]), 2)
for i in range(0, len(measured), 8)
).decode("ascii")

print(f"qubits: {len(bits)}")
print(f"decoded: {decoded!r}")
assert decoded == MESSAGE, f"round-trip failed: {decoded!r}"
print("round-trip OK")
<ul>
<li>Run <code>cargo fmt --all</code> before committing Rust.</li>
<li>Run <code>cargo clippy --workspace --all-targets</code>; fix or justify all warnings.</li>
<li>Run <code>cargo machete</code> to catch unused dependencies; it's also a <code>prek</code> hook, run on commit and in CI.</li>
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-30 14:58 UTC

@david-pl david-pl merged commit 2570637 into main Jun 30, 2026
15 checks passed
@david-pl david-pl deleted the david/machete branch June 30, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants