jps-pre-commit-utils
Custom pre-commit utilities for detecting debug/test leftovers, hardcoded paths, and environment-specific code
fragments in Python, Perl, and YAML files before they are committed.
These checks catch issues that are not easily detected by flake8, black, mypy, or bandit.
🧩 Features
✅ Scans staged diffs (git diff --cached) before commit
✅ Detects newly added lines containing:
- Debugging and testing statements (e.g.,
print,sys.exit,pdb.set_trace,logger.debug) - Hardcoded filesystem paths (e.g.,
/mnt/synth-genomics3/...) - Hardcoded environment variables or hostnames
- Inline comments with “test” or “TODO”
✅ Supports Python, Perl, and YAML files
✅ Configurable via.my-pre-commit-checks.yamlor~/.config/my-pre-commit-checks.yaml
✅ Integrates easily with manual usage or.pre-commit-config.yaml
🧩 Installation
pip install jps-pre-commit-utils
For local development:
git clone git@github.com:jai-python3/jps-pre-commit-utils.git
cd jps-pre-commit-utils
pip install -e '.[dev]'
🧩 Usage
Run manually:
jps-pre-commit-util-checks
Or integrate with Git pre-commit:
# .git/hooks/pre-commit
#!/bin/bash
python3 -m jps_pre_commit_utils.check_inserted_lines
🧩 Example Configuration
Configuration file:
.my-pre-commit-checks.yaml (in repo root)
or
~/.config/my-pre-commit-checks.yaml (global fallback)
# Example configuration for jps-pre-commit-utils
base_paths:
- /mnt/synth-genomics3
- /Users
ignore_patterns:
- /mnt/synth-genomics3/bioinfo/shared/
extra_regexes:
- "jira/[A-Z]+-[0-9]+"
🧩 Example Output
---------------------------------------------------------
🔧 Performing the following checks:
---------------------------------------------------------
• 🐍 Python debug/test statements
• 🐪 Perl debug/test statements
• 📁 Hardcoded absolute paths
• 🧪 Comments containing 'test' or 'testing'
---------------------------------------------------------
Scanning inserted lines ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% • 45/45
---------------------------------------------------------
🔍 Pre-commit inserted-line scan results
---------------------------------------------------------
⚠️ File: src/example.py, Line: 18
Added line contains pattern: "#[ ]*.*test"
→ # test
---------------------------------------------------------
⚠️ Total findings: 1
---------------------------------------------------------
🧱 Development
Install dependencies for linting, formatting, and testing:
make install-build-tools
Run all development checks:
make fix && make format && make lint
make test
🧪 Testing
make test
🧾 License
MIT License
© 2025 Jaideep Sundaram
🧠 Notes
- The utility is designed for use with Git repositories that follow a Gitflow workflow.
- Configuration is fully customizable; extend
.my-pre-commit-checks.yamlto add your own regexes. - Future versions will include additional checks for breakpoints, asserts, sleep statements, and other runtime risks.
🧩 Example Workflow
# Edit a file
echo '# test' >> src/sample.py
# Stage and check
git add src/sample.py
jps-pre-commit-checks
If issues are found, they are listed as warnings.
If none are found, you’ll see:
✅ No issues detected. (0 findings)
Metadata
Release files for jps-pre-commit-utils 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jps_pre_commit_utils-1.3.0.tar.gz | 15.1 kB | Without provenance | Details for jps_pre_commit_utils-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jps_pre_commit_utils-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for jps_pre_commit_utils-1.3.0-py3-none-any.whl |
Total release size: 26.4 kB
Release files / jps_pre_commit_utils-1.3.0.tar.gz
| Download URL | jps_pre_commit_utils-1.3.0.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4a0c023be060d32eb7f8bdc12d4f12477c0755e4130a9442dade6855771d70f
|
|
BLAKE2b-256 checksum How to use checksums |
3652aab731c8999b71dccf335db9c6b42ad4d9f3b60b68d17b5b3394554626f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / jps_pre_commit_utils-1.3.0-py3-none-any.whl
| Download URL | jps_pre_commit_utils-1.3.0-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
943d91de3e12d08ac017d47b13b22c3cee723b825e98b1b5000a948461836af5
|
|
BLAKE2b-256 checksum How to use checksums |
814e3ca441a5759dc89c5282444b3a78b635861b190faf600b50cd69565ecbef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for jps-pre-commit-utils 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.