Skip to content

Conversation

@lmmx
Copy link
Contributor

@lmmx lmmx commented Oct 14, 2025

Description

Following discussion in #880 and initial bug report in #872 (where found prek slower than pre-commit for the debug-statements hook in particular, which can be fixed by giving it a Rust port), this PR contributes such a "fast path" hook.

This is a popular hook with 5,000+ repos using it on grep.app

Like #884 this one uses the ruff_python_parser crate from ruff to parse the AST and then its closely related crate ruff_python_ast to access nodes.

  • The extra crate increased compilation time by 3%, from 21.7s to 22.4s (and I would expect this to be negligible difference to the change introduced by ruff_python_parser alone in the check-ast hook PR in feat(check-ast): implement builtin hook #884)
  • Unit test and snapshot test coverage added

Binary Size Change
+8.75% (.text: 16.0 MiB → 17.4 MiB)

Demo

Taking the top hit on grep.app, wandb/wandb

gh repo clone wandb/wandb

and running the latest release of prek and pre-commit, the debug-statements hook runs 26% slower than pre-commit's:

louis 🌟 ~/tmp/wandb $ pre-commit run -a --verbose
check-toml...............................................................Passed
- hook id: check-toml
- duration: 0.04s
debug-statements.........................................................Passed
- hook id: debug-statements
- duration: 0.19s
louis 🌟 ~/tmp/wandb $ prek run -a --verbose
check-toml...............................................................Passed
- hook id: check-toml
- duration: 0.00s
debug-statements.........................................................Passed
- hook id: debug-statements
- duration: 0.24s

After installing this local feature branch, it runs 2x as fast 🎉

louis 🌟 ~/tmp/wandb $ prek run -a --verbose
check-toml...............................................................Passed
- hook id: check-toml
- duration: 0.00s
debug-statements.........................................................Passed
- hook id: debug-statements
- duration: 0.10s

@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 97.38562% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.20%. Comparing base (7069606) to head (c94b21f).

Files with missing lines Patch % Lines
src/builtin/pre_commit_hooks/debug_statements.rs 97.36% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #886      +/-   ##
==========================================
+ Coverage   90.02%   90.20%   +0.18%     
==========================================
  Files          64       65       +1     
  Lines       11999    12305     +306     
==========================================
+ Hits        10802    11100     +298     
- Misses       1197     1205       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lmmx lmmx force-pushed the debug-statements branch from f4dc87b to c94b21f Compare October 19, 2025 10:27
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.

1 participant