# ๐ฏ Frappe Pre-commit
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/downloads/)
[](https://github.com/pre-commit/pre-commit)
**Comprehensive pre-commit hooks for Frappe Framework projects** to enforce coding standards, security practices, and best practices automatically.
## โจ Features
- ๐ก๏ธ **SQL Injection Prevention** - Detect and prevent SQL injection vulnerabilities
- ๐ **Translation Validation** - Ensure all user-facing strings are properly wrapped for internationalization
- ๐ **Coding Standards** - Enforce Frappe-specific coding conventions and best practices
- ๐ **DocType Naming** - Validate DocType and field naming conventions
- โก **Fast Execution** - Lightweight checks with minimal dependencies
- ๐ฏ **Customizable** - Pick and choose hooks based on your project needs
## ๐ Quick Start
### For New Frappe Projects
```bash
# 1. Initialize new Frappe app
bench new-app my_custom_app
cd apps/my_custom_app
# 2. Create .pre-commit-config.yaml
curl -o .pre-commit-config.yaml https://raw.githubusercontent.com/dhwani-ris/frappe-pre-commit/main/examples/.pre-commit-config.yaml
# 3. Install and run
pip install pre-commit
pre-commit install
pre-commit run --all-files
```
### For Existing Frappe Projects
```bash
# 1. Navigate to your app directory
cd apps/your_app
# 2. Add .pre-commit-config.yaml (see configuration below)
# 3. Install pre-commit
pip install pre-commit
pre-commit install
# 4. Run on existing code
pre-commit run --all-files
```
## ๐ Available Hooks
| Hook ID | Description | Files | Dependencies |
|---------|-------------|-------|--------------|
| `frappe-coding-standards` | General coding standards and best practices | `*.py` | None |
| `frappe-translation-check` | Translation wrapper validation | `*.py`, `*.js` | None |
| `frappe-sql-security` | SQL injection and security checks | `*.py` | None |
| `frappe-doctype-naming` | DocType and field naming conventions | `*.py`, `*.js`, `*.json` | `pyyaml` |
## โ๏ธ Configuration
### Basic Configuration
Create `.pre-commit-config.yaml` in your project root:
```yaml
repos:
# Frappe-specific hooks
- repo: https://github.com/dhwani-ris/frappe-pre-commit
rev: v1.0.0 # Use latest tag
hooks:
- id: frappe-translation-check
- id: frappe-sql-security
- id: frappe-coding-standards
# Code formatting (recommended)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.1
hooks:
- id: ruff
args: ["--select=I", "--fix"] # Import sorting
- id: ruff-format # Code formatting
# Additional quality checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
```
### Complete Configuration
```yaml
repos:
# Python formatting and linting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.1
hooks:
- id: ruff
name: "Ruff import sorter"
args: ["--select=I", "--fix"]
- id: ruff
name: "Ruff linter"
args: ["--extend-ignore=E501"]
- id: ruff-format
name: "Ruff formatter"
# JavaScript/CSS/JSON formatting
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
files: \.(js|jsx|ts|tsx|css|scss|json|md|yml|yaml)$
exclude: |
(?x)^(
.*\.min\.(js|css)$|
node_modules/.*|
.*/static/.*
)$
# Basic file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: \.(md|rst)$
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
- id: check-merge-conflict
- id: debug-statements
# Frappe-specific coding standards
- repo: https://github.com/dhwani-ris/frappe-pre-commit
rev: v1.0.0
hooks:
- id: frappe-coding-standards
# Exclude patterns
exclude: |
(?x)^(
.*/migrations/.*|
.*/patches/.*|
.*\.min\.(js|css)$|
node_modules/.*|
__pycache__/.*
)$
```
### Selective Hook Usage
```yaml
# Use only specific hooks you need
repos:
- repo: https://github.com/dhwani-ris/frappe-pre-commit
rev: v1.0.0
hooks:
- id: frappe-sql-security # Only SQL security checks
- id: frappe-translation-check # Only translation checks
```
## ๐ What Gets Checked
### ๐ก๏ธ SQL Security Checks
**Detects:**
- SQL injection vulnerabilities using `.format()` or f-strings
- String concatenation in SQL queries
- Unencrypted storage of sensitive data (passwords, API keys)
```python
# โ Will be flagged
frappe.db.sql("SELECT * FROM tabUser WHERE name = '{}'".format(user_name))
frappe.db.set_value("User", user, "password", plain_password)
# โ
Correct approach
frappe.db.sql("SELECT * FROM tabUser WHERE name = %s", user_name)
frappe.db.set_value("User", user, "password", frappe.utils.password.encrypt(plain_password))
```
### ๐ Translation Checks
**Ensures all user-facing strings are wrapped:**
```python
# โ Will be flagged
frappe.msgprint("Document saved successfully")
frappe.throw("Invalid email address")
# โ
Correct approach
frappe.msgprint(_("Document saved successfully"))
frappe.throw(_("Invalid email address"))
```
```javascript
// โ Will be flagged
frappe.msgprint("Document saved successfully");
// โ
Correct approach
frappe.msgprint(__("Document saved successfully"));
```
### ๐ Coding Standards
**Enforces:**
- Function length (โค20 lines recommended)
- Proper indentation (tabs, not spaces)
- Naming conventions (snake_case for functions, PascalCase for classes)
- Import organization
- Complexity limits (max nesting depth)
### ๐ DocType Naming Conventions
**Validates:**
- DocType names: Title Case with spaces (`"Sales Order"`)
- Field names: snake_case (`"customer_name"`)
- Field labels: Title Case (`"Customer Name"`)
## ๐๏ธ Integration Examples
### Integration with Bench
```bash
# For bench-managed projects
cd frappe-bench/apps/your_app
# Add pre-commit config
curl -o .pre-commit-config.yaml https://raw.githubusercontent.com/dhwani-ris/frappe-pre-commit/main/examples/.pre-commit-config.yaml
# Install globally in bench environment
~/frappe-bench/env/bin/pip install pre-commit
~/frappe-bench/env/bin/pre-commit install
```
### Integration with GitHub Actions
Create `.github/workflows/code-quality.yml`:
```yaml
name: Code Quality
on: [push, pull_request]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files
```
### Integration with VS Code
Add to `.vscode/settings.json`:
```json
{
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"python.sortImports.args": ["--profile", "black"],
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
}
```
## ๐งช Development and Testing
### Setting Up Development Environment
```bash
# Clone the repository
git clone https://github.com/dhwani-ris/frappe-pre-commit.git
cd frappe-pre-commit
# Create virtual environment
python -m venv dev_env
source dev_env/bin/activate # On Windows: dev_env\Scripts\activate
# Install development dependencies
pip install -r requirements-dev.txt
pip install pre-commit
# Install pre-commit hooks for this repository
pre-commit install
```
### Running Tests
```bash
# Test individual scripts
python scripts/check_coding_standards.py test_files/sample.py
python scripts/check_sql_security.py test_files/sample.py
python scripts/check_translations.py test_files/sample.py
# Test all hooks
python test_scripts/test_all_hooks.py
# Test with pre-commit
pre-commit run --all-files
```
### Creating Test Files
```bash
# Create test files with issues
mkdir test_project && cd test_project
# Create Python file with intentional issues
cat > bad_example.py << 'EOF'
import frappe
def very_long_function_that_violates_standards():
frappe.msgprint("Missing translation wrapper")
result = frappe.db.sql("SELECT * FROM tabUser WHERE name = '{}'".format("test"))
return result
EOF
# Test your hooks
cd ../
python scripts/check_translations.py test_project/bad_example.py
python scripts/check_sql_security.py test_project/bad_example.py
```
### Testing with Different Frappe Projects
```bash
# Test with ERPNext
cd path/to/erpnext
git clone https://github.com/dhwani-ris/frappe-pre-commit.git .pre-commit-hooks
cp .pre-commit-hooks/examples/.pre-commit-config.yaml .
pre-commit install
pre-commit run --all-files
# Test with custom app
cd path/to/your_custom_app
# Same process as above
```
### Contributing
1. **Fork the repository**
2. **Create feature branch**: `git checkout -b feature/new-check`
3. **Add your hook script** in `scripts/`
4. **Update `.pre-commit-hooks.yaml`**
5. **Add tests** in `test_scripts/`
6. **Update documentation**
7. **Submit pull request**
## ๐ Examples
### Example 1: Basic Frappe App Setup
```bash
# Create new app
cd frappe-bench
bench new-app inventory_management
cd apps/inventory_management
# Add pre-commit
cat > .pre-commit-config.yaml << 'EOF'
repos:
- repo: https://github.com/dhwani-ris/frappe-pre-commit
rev: v1.0.0
hooks:
- id: frappe-quick-check
EOF
# Install and test
pip install pre-commit
pre-commit install
pre-commit run --all-files
```
### Example 2: ERPNext Customization
```bash
# For ERPNext customizations
cd frappe-bench/apps/erpnext
# Use comprehensive config
curl -o .pre-commit-config.yaml https://raw.githubusercontent.com/dhwani-ris/frappe-pre-commit/main/examples/erpnext-config.yaml
pre-commit install
pre-commit run --all-files
```
### Example 3: CI/CD Integration
```yaml
# .github/workflows/quality-check.yml
name: Quality Check
on:
pull_request:
branches: [main, develop]
jobs:
code-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install pre-commit
pip install -r requirements.txt
- name: Run pre-commit
run: pre-commit run --all-files
- name: Comment PR
if: failure()
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'โ Code quality checks failed. Please run `pre-commit run --all-files` locally and fix the issues.'
})
```
## ๐ง Troubleshooting
### Common Issues
**Pre-commit hooks not running:**
```bash
pre-commit uninstall
pre-commit install
pre-commit run --all-files
```
**Hooks failing on large files:**
```bash
# Skip hooks for specific commit
git commit -m "Large file update" --no-verify
# Or exclude large files in config
# Add to .pre-commit-config.yaml:
exclude: |
(?x)^(
large_files/.*|
.*\.min\.js$
)$
```
**Import errors in scripts:**
```bash
# Make sure Python can find the scripts
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
```
### Performance Tips
```bash
# Cache pre-commit environments
export PRE_COMMIT_HOME=~/.cache/pre-commit
# Run only on changed files
pre-commit run
# Skip slow hooks during development
PRE_COMMIT_SKIP=frappe-all-checks git commit -m "Quick fix"
```
## ๐ค Contributing
We welcome contributions!
### Quick Contribution Steps
1. Fork the repository
2. Clone your fork: `git clone https://github.com/yourusername/frappe-pre-commit.git`
3. Create branch: `git checkout -b feature/improvement`
4. Make changes and test thoroughly
5. Submit pull request
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ข About
Maintained by **Dhwani RIS**
- ๐ **Website**: [dhwaniris.com](https://dhwaniris.com)
- ๐ **GitHub**: [@dhwani-ris](https://github.com/dhwani-ris)
---
**Ready to improve your Frappe code quality?** Get started with Frappe-Pre-commit today! ๐
```bash
# Install pre-commit and the frappe-pre-commit package
pip install pre-commit frappe-pre-commit
# Download the pre-commit configuration
curl -o .pre-commit-config.yaml https://raw.githubusercontent.com/dhwani-ris/frappe-pre-commit/main/examples/.pre-commit-config.yaml
# Install the pre-commit hooks
pre-commit install
# Run all checks
pre-commit run --all-files
```
Raw data
{
"_id": null,
"home_page": "https://github.com/dhwani-ris/frappe-pre-commit",
"name": "frappe-pre-commit",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "frappe, erpnext, pre-commit, hooks, code-quality",
"author": "Bhushan Barbuddhe",
"author_email": "Bhushan Barbuddhe <bhushan.barbuddhe@dhwaniris.com>",
"download_url": "https://files.pythonhosted.org/packages/98/56/46a80bb659987aa15c4317b5d1b0624ed9578e1ea3b5b70dde16fdb7ed3c/frappe_pre_commit-1.0.0.tar.gz",
"platform": null,
"description": "# \ud83c\udfaf Frappe Pre-commit\n\n[](https://opensource.org/licenses/MIT)\n[](https://www.python.org/downloads/)\n[](https://github.com/pre-commit/pre-commit)\n\n**Comprehensive pre-commit hooks for Frappe Framework projects** to enforce coding standards, security practices, and best practices automatically.\n\n## \u2728 Features\n\n- \ud83d\udee1\ufe0f **SQL Injection Prevention** - Detect and prevent SQL injection vulnerabilities\n- \ud83c\udf10 **Translation Validation** - Ensure all user-facing strings are properly wrapped for internationalization\n- \ud83d\udccf **Coding Standards** - Enforce Frappe-specific coding conventions and best practices\n- \ud83d\udcdd **DocType Naming** - Validate DocType and field naming conventions\n- \u26a1 **Fast Execution** - Lightweight checks with minimal dependencies\n- \ud83c\udfaf **Customizable** - Pick and choose hooks based on your project needs\n\n## \ud83d\ude80 Quick Start\n\n### For New Frappe Projects\n\n```bash\n# 1. Initialize new Frappe app\nbench new-app my_custom_app\ncd apps/my_custom_app\n\n# 2. Create .pre-commit-config.yaml\ncurl -o .pre-commit-config.yaml https://raw.githubusercontent.com/dhwani-ris/frappe-pre-commit/main/examples/.pre-commit-config.yaml\n\n# 3. Install and run\npip install pre-commit\npre-commit install\npre-commit run --all-files\n```\n\n### For Existing Frappe Projects\n\n```bash\n# 1. Navigate to your app directory\ncd apps/your_app\n\n# 2. Add .pre-commit-config.yaml (see configuration below)\n# 3. Install pre-commit\npip install pre-commit\npre-commit install\n\n# 4. Run on existing code\npre-commit run --all-files\n```\n\n## \ud83d\udccb Available Hooks\n\n| Hook ID | Description | Files | Dependencies |\n|---------|-------------|-------|--------------|\n| `frappe-coding-standards` | General coding standards and best practices | `*.py` | None |\n| `frappe-translation-check` | Translation wrapper validation | `*.py`, `*.js` | None |\n| `frappe-sql-security` | SQL injection and security checks | `*.py` | None |\n| `frappe-doctype-naming` | DocType and field naming conventions | `*.py`, `*.js`, `*.json` | `pyyaml` |\n\n## \u2699\ufe0f Configuration\n\n### Basic Configuration\n\nCreate `.pre-commit-config.yaml` in your project root:\n\n```yaml\nrepos:\n # Frappe-specific hooks\n - repo: https://github.com/dhwani-ris/frappe-pre-commit\n rev: v1.0.0 # Use latest tag\n hooks:\n - id: frappe-translation-check\n - id: frappe-sql-security\n - id: frappe-coding-standards\n\n # Code formatting (recommended)\n - repo: https://github.com/astral-sh/ruff-pre-commit\n rev: v0.8.1\n hooks:\n - id: ruff\n args: [\"--select=I\", \"--fix\"] # Import sorting\n - id: ruff-format # Code formatting\n\n # Additional quality checks\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.5.0\n hooks:\n - id: trailing-whitespace\n - id: end-of-file-fixer\n - id: check-yaml\n - id: check-json\n```\n\n### Complete Configuration\n\n```yaml\nrepos:\n # Python formatting and linting\n - repo: https://github.com/astral-sh/ruff-pre-commit\n rev: v0.8.1\n hooks:\n - id: ruff\n name: \"Ruff import sorter\"\n args: [\"--select=I\", \"--fix\"]\n - id: ruff\n name: \"Ruff linter\"\n args: [\"--extend-ignore=E501\"]\n - id: ruff-format\n name: \"Ruff formatter\"\n\n # JavaScript/CSS/JSON formatting\n - repo: https://github.com/pre-commit/mirrors-prettier\n rev: v4.0.0-alpha.8\n hooks:\n - id: prettier\n files: \\.(js|jsx|ts|tsx|css|scss|json|md|yml|yaml)$\n exclude: |\n (?x)^(\n .*\\.min\\.(js|css)$|\n node_modules/.*|\n .*/static/.*\n )$\n\n # Basic file checks\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.5.0\n hooks:\n - id: trailing-whitespace\n exclude: \\.(md|rst)$\n - id: end-of-file-fixer\n - id: check-yaml\n - id: check-json\n - id: check-merge-conflict\n - id: debug-statements\n\n # Frappe-specific coding standards\n - repo: https://github.com/dhwani-ris/frappe-pre-commit\n rev: v1.0.0\n hooks:\n - id: frappe-coding-standards \n\n# Exclude patterns\nexclude: |\n (?x)^(\n .*/migrations/.*|\n .*/patches/.*|\n .*\\.min\\.(js|css)$|\n node_modules/.*|\n __pycache__/.*\n )$\n```\n\n### Selective Hook Usage\n\n```yaml\n# Use only specific hooks you need\nrepos:\n - repo: https://github.com/dhwani-ris/frappe-pre-commit\n rev: v1.0.0\n hooks:\n - id: frappe-sql-security # Only SQL security checks\n - id: frappe-translation-check # Only translation checks\n```\n\n## \ud83d\udd0d What Gets Checked\n\n### \ud83d\udee1\ufe0f SQL Security Checks\n\n**Detects:**\n- SQL injection vulnerabilities using `.format()` or f-strings\n- String concatenation in SQL queries\n- Unencrypted storage of sensitive data (passwords, API keys)\n\n```python\n# \u274c Will be flagged\nfrappe.db.sql(\"SELECT * FROM tabUser WHERE name = '{}'\".format(user_name))\nfrappe.db.set_value(\"User\", user, \"password\", plain_password)\n\n# \u2705 Correct approach\nfrappe.db.sql(\"SELECT * FROM tabUser WHERE name = %s\", user_name)\nfrappe.db.set_value(\"User\", user, \"password\", frappe.utils.password.encrypt(plain_password))\n```\n\n### \ud83c\udf10 Translation Checks\n\n**Ensures all user-facing strings are wrapped:**\n\n```python\n# \u274c Will be flagged\nfrappe.msgprint(\"Document saved successfully\")\nfrappe.throw(\"Invalid email address\")\n\n# \u2705 Correct approach\nfrappe.msgprint(_(\"Document saved successfully\"))\nfrappe.throw(_(\"Invalid email address\"))\n```\n\n```javascript\n// \u274c Will be flagged\nfrappe.msgprint(\"Document saved successfully\");\n\n// \u2705 Correct approach\nfrappe.msgprint(__(\"Document saved successfully\"));\n```\n\n### \ud83d\udccf Coding Standards\n\n**Enforces:**\n- Function length (\u226420 lines recommended)\n- Proper indentation (tabs, not spaces)\n- Naming conventions (snake_case for functions, PascalCase for classes)\n- Import organization\n- Complexity limits (max nesting depth)\n\n### \ud83d\udcdd DocType Naming Conventions\n\n**Validates:**\n- DocType names: Title Case with spaces (`\"Sales Order\"`)\n- Field names: snake_case (`\"customer_name\"`)\n- Field labels: Title Case (`\"Customer Name\"`)\n\n## \ud83c\udfd7\ufe0f Integration Examples\n\n### Integration with Bench\n\n```bash\n# For bench-managed projects\ncd frappe-bench/apps/your_app\n\n# Add pre-commit config\ncurl -o .pre-commit-config.yaml https://raw.githubusercontent.com/dhwani-ris/frappe-pre-commit/main/examples/.pre-commit-config.yaml\n\n# Install globally in bench environment\n~/frappe-bench/env/bin/pip install pre-commit\n~/frappe-bench/env/bin/pre-commit install\n```\n\n### Integration with GitHub Actions\n\nCreate `.github/workflows/code-quality.yml`:\n\n```yaml\nname: Code Quality\n\non: [push, pull_request]\n\njobs:\n pre-commit:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: '3.10'\n - name: Install pre-commit\n run: pip install pre-commit\n - name: Run pre-commit\n run: pre-commit run --all-files\n```\n\n### Integration with VS Code\n\nAdd to `.vscode/settings.json`:\n\n```json\n{\n \"python.linting.enabled\": true,\n \"python.linting.flake8Enabled\": true,\n \"python.formatting.provider\": \"black\",\n \"editor.formatOnSave\": true,\n \"python.sortImports.args\": [\"--profile\", \"black\"],\n \"[python]\": {\n \"editor.codeActionsOnSave\": {\n \"source.organizeImports\": true\n }\n }\n}\n```\n\n## \ud83e\uddea Development and Testing\n\n### Setting Up Development Environment\n\n```bash\n# Clone the repository\ngit clone https://github.com/dhwani-ris/frappe-pre-commit.git\ncd frappe-pre-commit\n\n# Create virtual environment\npython -m venv dev_env\nsource dev_env/bin/activate # On Windows: dev_env\\Scripts\\activate\n\n# Install development dependencies\npip install -r requirements-dev.txt\npip install pre-commit\n\n# Install pre-commit hooks for this repository\npre-commit install\n```\n\n### Running Tests\n\n```bash\n# Test individual scripts\npython scripts/check_coding_standards.py test_files/sample.py\npython scripts/check_sql_security.py test_files/sample.py\npython scripts/check_translations.py test_files/sample.py\n\n# Test all hooks\npython test_scripts/test_all_hooks.py\n\n# Test with pre-commit\npre-commit run --all-files\n```\n\n### Creating Test Files\n\n```bash\n# Create test files with issues\nmkdir test_project && cd test_project\n\n# Create Python file with intentional issues\ncat > bad_example.py << 'EOF'\nimport frappe\n\ndef very_long_function_that_violates_standards():\n frappe.msgprint(\"Missing translation wrapper\")\n result = frappe.db.sql(\"SELECT * FROM tabUser WHERE name = '{}'\".format(\"test\"))\n return result\nEOF\n\n# Test your hooks\ncd ../\npython scripts/check_translations.py test_project/bad_example.py\npython scripts/check_sql_security.py test_project/bad_example.py\n```\n\n### Testing with Different Frappe Projects\n\n```bash\n# Test with ERPNext\ncd path/to/erpnext\ngit clone https://github.com/dhwani-ris/frappe-pre-commit.git .pre-commit-hooks\ncp .pre-commit-hooks/examples/.pre-commit-config.yaml .\npre-commit install\npre-commit run --all-files\n\n# Test with custom app\ncd path/to/your_custom_app\n# Same process as above\n```\n\n### Contributing\n\n1. **Fork the repository**\n2. **Create feature branch**: `git checkout -b feature/new-check`\n3. **Add your hook script** in `scripts/`\n4. **Update `.pre-commit-hooks.yaml`**\n5. **Add tests** in `test_scripts/`\n6. **Update documentation**\n7. **Submit pull request**\n\n## \ud83d\udcda Examples\n\n### Example 1: Basic Frappe App Setup\n\n```bash\n# Create new app\ncd frappe-bench\nbench new-app inventory_management\ncd apps/inventory_management\n\n# Add pre-commit\ncat > .pre-commit-config.yaml << 'EOF'\nrepos:\n - repo: https://github.com/dhwani-ris/frappe-pre-commit\n rev: v1.0.0\n hooks:\n - id: frappe-quick-check\nEOF\n\n# Install and test\npip install pre-commit\npre-commit install\npre-commit run --all-files\n```\n\n### Example 2: ERPNext Customization\n\n```bash\n# For ERPNext customizations\ncd frappe-bench/apps/erpnext\n\n# Use comprehensive config\ncurl -o .pre-commit-config.yaml https://raw.githubusercontent.com/dhwani-ris/frappe-pre-commit/main/examples/erpnext-config.yaml\n\npre-commit install\npre-commit run --all-files\n```\n\n### Example 3: CI/CD Integration\n\n```yaml\n# .github/workflows/quality-check.yml\nname: Quality Check\n\non:\n pull_request:\n branches: [main, develop]\n\njobs:\n code-quality:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n \n - name: Set up Python\n uses: actions/setup-python@v4\n with:\n python-version: '3.10'\n \n - name: Install dependencies\n run: |\n pip install pre-commit\n pip install -r requirements.txt\n \n - name: Run pre-commit\n run: pre-commit run --all-files\n \n - name: Comment PR\n if: failure()\n uses: actions/github-script@v6\n with:\n script: |\n github.rest.issues.createComment({\n issue_number: context.issue.number,\n owner: context.repo.owner,\n repo: context.repo.repo,\n body: '\u274c Code quality checks failed. Please run `pre-commit run --all-files` locally and fix the issues.'\n })\n```\n\n## \ud83d\udd27 Troubleshooting\n\n### Common Issues\n\n**Pre-commit hooks not running:**\n```bash\npre-commit uninstall\npre-commit install\npre-commit run --all-files\n```\n\n**Hooks failing on large files:**\n```bash\n# Skip hooks for specific commit\ngit commit -m \"Large file update\" --no-verify\n\n# Or exclude large files in config\n# Add to .pre-commit-config.yaml:\nexclude: |\n (?x)^(\n large_files/.*|\n .*\\.min\\.js$\n )$\n```\n\n**Import errors in scripts:**\n```bash\n# Make sure Python can find the scripts\nexport PYTHONPATH=\"${PYTHONPATH}:$(pwd)\"\n```\n\n### Performance Tips\n\n```bash\n# Cache pre-commit environments\nexport PRE_COMMIT_HOME=~/.cache/pre-commit\n\n# Run only on changed files\npre-commit run\n\n# Skip slow hooks during development\nPRE_COMMIT_SKIP=frappe-all-checks git commit -m \"Quick fix\"\n```\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! \n\n### Quick Contribution Steps\n\n1. Fork the repository\n2. Clone your fork: `git clone https://github.com/yourusername/frappe-pre-commit.git`\n3. Create branch: `git checkout -b feature/improvement`\n4. Make changes and test thoroughly\n5. Submit pull request\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83c\udfe2 About\n\nMaintained by **Dhwani RIS** \n\n- \ud83c\udf10 **Website**: [dhwaniris.com](https://dhwaniris.com)\n- \ud83d\udc19 **GitHub**: [@dhwani-ris](https://github.com/dhwani-ris)\n\n\n---\n\n**Ready to improve your Frappe code quality?** Get started with Frappe-Pre-commit today! \ud83d\ude80\n\n```bash\n# Install pre-commit and the frappe-pre-commit package\npip install pre-commit frappe-pre-commit\n\n# Download the pre-commit configuration\ncurl -o .pre-commit-config.yaml https://raw.githubusercontent.com/dhwani-ris/frappe-pre-commit/main/examples/.pre-commit-config.yaml\n\n# Install the pre-commit hooks\npre-commit install\n\n# Run all checks\npre-commit run --all-files\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Pre-commit hooks for Frappe Framework coding standards",
"version": "1.0.0",
"project_urls": {
"Bug Tracker": "https://github.com/dhwani-ris/frappe-pre-commit/issues",
"Changelog": "https://github.com/dhwani-ris/frappe-pre-commit/blob/main/CHANGELOG.md",
"Documentation": "https://github.com/dhwani-ris/frappe-pre-commit#readme",
"Homepage": "https://github.com/dhwani-ris/frappe-pre-commit",
"Repository": "https://github.com/dhwani-ris/frappe-pre-commit"
},
"split_keywords": [
"frappe",
" erpnext",
" pre-commit",
" hooks",
" code-quality"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "63fec5806c2b0df8d0f231998d8bc46551d655dc8686c188aeef883e8072710f",
"md5": "1bf5dd737623dbcd0225eafd652f97bf",
"sha256": "1a808a173ecdf0b547a251f21d3872bad9dad526fe38e9bcb2155cd0acfd1d78"
},
"downloads": -1,
"filename": "frappe_pre_commit-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1bf5dd737623dbcd0225eafd652f97bf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 14599,
"upload_time": "2025-07-18T09:16:54",
"upload_time_iso_8601": "2025-07-18T09:16:54.286886Z",
"url": "https://files.pythonhosted.org/packages/63/fe/c5806c2b0df8d0f231998d8bc46551d655dc8686c188aeef883e8072710f/frappe_pre_commit-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "985646a80bb659987aa15c4317b5d1b0624ed9578e1ea3b5b70dde16fdb7ed3c",
"md5": "eac33bf6318c892c5b2dcba072cf4623",
"sha256": "cc668a281057e0aca2e644ab547d3875068ba6f87c12c7670938b746697a72dc"
},
"downloads": -1,
"filename": "frappe_pre_commit-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "eac33bf6318c892c5b2dcba072cf4623",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 12741,
"upload_time": "2025-07-18T09:16:55",
"upload_time_iso_8601": "2025-07-18T09:16:55.986589Z",
"url": "https://files.pythonhosted.org/packages/98/56/46a80bb659987aa15c4317b5d1b0624ed9578e1ea3b5b70dde16fdb7ed3c/frappe_pre_commit-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-18 09:16:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dhwani-ris",
"github_project": "frappe-pre-commit",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "frappe-pre-commit"
}