|
| 1 | +# Pre-commit hooks for predicate-secure repository |
| 2 | + |
| 3 | +repos: |
| 4 | + # General file checks |
| 5 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 6 | + rev: v4.5.0 |
| 7 | + hooks: |
| 8 | + - id: trailing-whitespace |
| 9 | + - id: end-of-file-fixer |
| 10 | + - id: check-yaml |
| 11 | + - id: check-json |
| 12 | + - id: check-added-large-files |
| 13 | + args: ["--maxkb=1000"] |
| 14 | + - id: check-merge-conflict |
| 15 | + - id: check-case-conflict |
| 16 | + - id: detect-private-key |
| 17 | + - id: debug-statements |
| 18 | + - id: mixed-line-ending |
| 19 | + args: ["--fix=lf"] |
| 20 | + |
| 21 | + # Python code formatting with Black |
| 22 | + - repo: https://github.com/psf/black |
| 23 | + rev: 24.2.0 |
| 24 | + hooks: |
| 25 | + - id: black |
| 26 | + language_version: python3.11 |
| 27 | + args: ["--line-length=100"] |
| 28 | + exclude: ^(venv/|\.venv/|build/|dist/) |
| 29 | + |
| 30 | + # Import sorting with isort (compatible with Black) |
| 31 | + - repo: https://github.com/pycqa/isort |
| 32 | + rev: 5.13.2 |
| 33 | + hooks: |
| 34 | + - id: isort |
| 35 | + args: ["--profile=black", "--line-length=100"] |
| 36 | + exclude: ^(venv/|\.venv/|build/|dist/) |
| 37 | + |
| 38 | + # Flake8 for style guide enforcement |
| 39 | + - repo: https://github.com/pycqa/flake8 |
| 40 | + rev: 7.0.0 |
| 41 | + hooks: |
| 42 | + - id: flake8 |
| 43 | + args: |
| 44 | + - "--max-line-length=100" |
| 45 | + - "--extend-ignore=E203,W503,E501" # Black compatibility |
| 46 | + - "--exclude=venv,build,dist,.eggs,*.egg" |
| 47 | + - "--max-complexity=15" |
| 48 | + exclude: ^(venv/|\.venv/|build/|dist/) |
| 49 | + |
| 50 | + # Type checking with mypy |
| 51 | + - repo: https://github.com/pre-commit/mirrors-mypy |
| 52 | + rev: v1.8.0 |
| 53 | + hooks: |
| 54 | + - id: mypy |
| 55 | + additional_dependencies: |
| 56 | + - pydantic>=2.0 |
| 57 | + - types-requests |
| 58 | + args: |
| 59 | + - "--ignore-missing-imports" |
| 60 | + - "--no-strict-optional" |
| 61 | + - "--warn-unused-ignores" |
| 62 | + exclude: ^(tests/|examples/|venv/|\.venv/|build/|dist/) |
| 63 | + |
| 64 | + # Security checks |
| 65 | + - repo: https://github.com/PyCQA/bandit |
| 66 | + rev: 1.7.7 |
| 67 | + hooks: |
| 68 | + - id: bandit |
| 69 | + args: ["-c", "pyproject.toml"] |
| 70 | + additional_dependencies: ["bandit[toml]"] |
| 71 | + exclude: ^(tests/|venv/|\.venv/) |
| 72 | + |
| 73 | + # Check for common Python anti-patterns |
| 74 | + - repo: https://github.com/asottile/pyupgrade |
| 75 | + rev: v3.15.0 |
| 76 | + hooks: |
| 77 | + - id: pyupgrade |
| 78 | + args: ["--py311-plus"] |
| 79 | + exclude: ^(venv/|\.venv/|build/|dist/) |
| 80 | + |
| 81 | + # Markdown linting for docs-heavy workflows |
| 82 | + - repo: https://github.com/DavidAnson/markdownlint-cli2 |
| 83 | + rev: v0.14.0 |
| 84 | + hooks: |
| 85 | + - id: markdownlint-cli2 |
| 86 | + args: ["--config", ".markdownlint.yaml"] |
| 87 | + files: \.md$ |
| 88 | + |
| 89 | +default_language_version: |
| 90 | + python: python3.11 |
| 91 | + |
| 92 | +fail_fast: false |
| 93 | + |
| 94 | +exclude: | |
| 95 | + (?x)^( |
| 96 | + venv/.*| |
| 97 | + \.venv/.*| |
| 98 | + build/.*| |
| 99 | + dist/.*| |
| 100 | + \.eggs/.*| |
| 101 | + .*\.egg-info/.*| |
| 102 | + __pycache__/.*| |
| 103 | + \.pytest_cache/.*| |
| 104 | + \.mypy_cache/.*| |
| 105 | + \.ruff_cache/.*| |
| 106 | + \.pre-commit-cache/.* |
| 107 | + )$ |
0 commit comments