# jps-pre-commit-utils


[](https://codecov.io/gh/jai-python3/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.yaml` or `~/.config/my-pre-commit-checks.yaml`
β
Integrates easily with manual usage or `.pre-commit-config.yaml`
---
## π§© Installation
```bash
pip install jps-pre-commit-utils
```
For local development:
```bash
git clone git@github.com:jai-python3/jps-pre-commit-utils.git
cd jps-pre-commit-utils
pip install -e '.[dev]'
```
---
## π§© Usage
Run manually:
```bash
jps-pre-commit-checks
```
Or integrate with Git pre-commit:
```bash
# .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)*
```yaml
# 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
```bash
---------------------------------------------------------
π§ 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:
```bash
pip install -e '.[dev]'
```
Run all development checks:
```bash
make lint
make test
```
Build the distribution:
```bash
make build
```
---
## π§ͺ Testing
```bash
pytest -v --disable-warnings
```
---
## π Publishing
```bash
make publish
```
This command builds and uploads the package to PyPI via `twine`.
---
## π§Ύ 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.yaml` to add your own regexes.
- Future versions will include additional checks for breakpoints, asserts, sleep statements, and other runtime risks.
---
### π§© Example Workflow
```bash
# 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:
```bash
β
No issues detected. (0 findings)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "jps-pre-commit-utils",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "pre-commit, git, lint, static-analysis, utilities",
"author": "Jaideep Sundaram",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/f8/6e/4c971e2d2438dc5dce67fc8647559c2421a09a87796a5dd21adf625ceedd/jps_pre_commit_utils-1.2.0.tar.gz",
"platform": null,
"description": "# jps-pre-commit-utils\n\n\n\n[](https://codecov.io/gh/jai-python3/jps-pre-commit-utils)\n\n\nCustom pre-commit utilities for detecting debug/test leftovers, hardcoded paths, and environment-specific code fragments \nin Python, Perl, and YAML files before they are committed. \nThese checks catch issues that are not easily detected by flake8, black, mypy, or bandit.\n\n---\n\n## \ud83e\udde9 Features\n\n\u2705 Scans *staged diffs* (`git diff --cached`) before commit \n\u2705 Detects newly added lines containing:\n- Debugging and testing statements (e.g., `print`, `sys.exit`, `pdb.set_trace`, `logger.debug`)\n- Hardcoded filesystem paths (e.g., `/mnt/synth-genomics3/...`)\n- Hardcoded environment variables or hostnames\n- Inline comments with \u201ctest\u201d or \u201cTODO\u201d\n\u2705 Supports **Python**, **Perl**, and **YAML** files \n\u2705 Configurable via `.my-pre-commit-checks.yaml` or `~/.config/my-pre-commit-checks.yaml` \n\u2705 Integrates easily with manual usage or `.pre-commit-config.yaml`\n\n---\n\n## \ud83e\udde9 Installation\n\n```bash\npip install jps-pre-commit-utils\n```\n\nFor local development:\n\n```bash\ngit clone git@github.com:jai-python3/jps-pre-commit-utils.git\ncd jps-pre-commit-utils\npip install -e '.[dev]'\n```\n\n---\n\n## \ud83e\udde9 Usage\n\nRun manually:\n\n```bash\njps-pre-commit-checks\n```\n\nOr integrate with Git pre-commit:\n\n```bash\n# .git/hooks/pre-commit\n#!/bin/bash\npython3 -m jps_pre_commit_utils.check_inserted_lines\n```\n\n---\n\n## \ud83e\udde9 Example Configuration\n\nConfiguration file: \n`.my-pre-commit-checks.yaml` *(in repo root)* \nor \n`~/.config/my-pre-commit-checks.yaml` *(global fallback)*\n\n```yaml\n# Example configuration for jps-pre-commit-utils\nbase_paths:\n - /mnt/synth-genomics3\n - /Users\nignore_patterns:\n - /mnt/synth-genomics3/bioinfo/shared/\nextra_regexes:\n - \"jira/[A-Z]+-[0-9]+\"\n```\n\n---\n\n## \ud83e\udde9 Example Output\n\n```bash\n---------------------------------------------------------\n\ud83d\udd27 Performing the following checks:\n---------------------------------------------------------\n\u2022 \ud83d\udc0d Python debug/test statements\n\u2022 \ud83d\udc2a Perl debug/test statements\n\u2022 \ud83d\udcc1 Hardcoded absolute paths\n\u2022 \ud83e\uddea Comments containing 'test' or 'testing'\n---------------------------------------------------------\nScanning inserted lines \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 100% \u2022 45/45\n---------------------------------------------------------\n\ud83d\udd0d Pre-commit inserted-line scan results\n---------------------------------------------------------\n\u26a0\ufe0f File: src/example.py, Line: 18\n Added line contains pattern: \"#[ \t]*.*test\"\n \u2192 # test\n---------------------------------------------------------\n\u26a0\ufe0f Total findings: 1\n---------------------------------------------------------\n```\n\n---\n\n## \ud83e\uddf1 Development\n\nInstall dependencies for linting, formatting, and testing:\n\n```bash\npip install -e '.[dev]'\n```\n\nRun all development checks:\n\n```bash\nmake lint\nmake test\n```\n\nBuild the distribution:\n\n```bash\nmake build\n```\n\n---\n\n## \ud83e\uddea Testing\n\n```bash\npytest -v --disable-warnings\n```\n\n---\n\n## \ud83d\ude80 Publishing\n\n```bash\nmake publish\n```\n\nThis command builds and uploads the package to PyPI via `twine`.\n\n---\n\n## \ud83e\uddfe License\n\nMIT License \n\u00a9 2025 Jaideep Sundaram\n\n---\n\n## \ud83e\udde0 Notes\n\n- The utility is designed for use with Git repositories that follow a Gitflow workflow. \n- Configuration is fully customizable; extend `.my-pre-commit-checks.yaml` to add your own regexes. \n- Future versions will include additional checks for breakpoints, asserts, sleep statements, and other runtime risks. \n\n---\n\n### \ud83e\udde9 Example Workflow\n\n```bash\n# Edit a file\necho '# test' >> src/sample.py\n\n# Stage and check\ngit add src/sample.py\njps-pre-commit-checks\n```\n\nIf issues are found, they are listed as warnings. \nIf none are found, you\u2019ll see:\n\n```bash\n\u2705 No issues detected. (0 findings)\n```\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Custom pre-commit utility for scanning diffs for debug/test patterns, hardcoded paths, and other configurable checks.",
"version": "1.2.0",
"project_urls": {
"Homepage": "https://github.com/jai-python3/jps-pre-commit-utils",
"Issues": "https://github.com/jai-python3/jps-pre-commit-utils/issues",
"Repository": "https://github.com/jai-python3/jps-pre-commit-utils"
},
"split_keywords": [
"pre-commit",
" git",
" lint",
" static-analysis",
" utilities"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "260469f63c1c6e990c4de1f724e986c182a2436716971998e95dcebfa8b65bb8",
"md5": "6fccd24365de3b507651341222584fd7",
"sha256": "0c8a5a30c9edcc02e06a84914a8e32d3f371f9080186c07fc22d4b91c0fe8e28"
},
"downloads": -1,
"filename": "jps_pre_commit_utils-1.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6fccd24365de3b507651341222584fd7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 7225,
"upload_time": "2025-11-01T16:25:39",
"upload_time_iso_8601": "2025-11-01T16:25:39.590371Z",
"url": "https://files.pythonhosted.org/packages/26/04/69f63c1c6e990c4de1f724e986c182a2436716971998e95dcebfa8b65bb8/jps_pre_commit_utils-1.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f86e4c971e2d2438dc5dce67fc8647559c2421a09a87796a5dd21adf625ceedd",
"md5": "a1e7d4fccb15db3fe093ada8fd59c0a7",
"sha256": "0c491d2292d5146a5e9c4ece0ca6e0516acfa3c4ec92a1681f5ee03d52255dad"
},
"downloads": -1,
"filename": "jps_pre_commit_utils-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "a1e7d4fccb15db3fe093ada8fd59c0a7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 7458,
"upload_time": "2025-11-01T16:25:40",
"upload_time_iso_8601": "2025-11-01T16:25:40.627978Z",
"url": "https://files.pythonhosted.org/packages/f8/6e/4c971e2d2438dc5dce67fc8647559c2421a09a87796a5dd21adf625ceedd/jps_pre_commit_utils-1.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-11-01 16:25:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jai-python3",
"github_project": "jps-pre-commit-utils",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "jps-pre-commit-utils"
}