forked from kenmcmil/ivy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
80 lines (73 loc) · 2.42 KB
/
.pre-commit-config.yaml
File metadata and controls
80 lines (73 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Pre-commit configuration for panther_ivy submodule
#
# Three-tier approach:
# Tier 1 - Plugin code (root .py files): Full formatting + linting
# (ivy_lsp/ and tests/ are now in the ivy-lsp submodule with their own hooks)
# Tier 2 - Upstream ivy/ code: Hygiene only (whitespace, merge conflicts)
# Tier 3 - Everything else (.ivy, templates, YAML, C++): Hygiene only
#
# Usage:
# pre-commit install
# pre-commit run --all-files # Auto-commit hooks
# pre-commit run --hook-stage manual --all-files # Manual hooks (flake8, bandit, hadolint)
repos:
# === Hygiene hooks (all tiers) ===
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: ^(submodules/|__pycache__/|build/|dist/|.*\.egg-info/|protocol-testing/apt/test/)
- id: end-of-file-fixer
exclude: ^(submodules/|__pycache__/|build/|dist/|.*\.egg-info/|protocol-testing/apt/test/)
- id: check-yaml
args: ['--allow-multiple-documents']
exclude: ^(submodules/|templates/)
- id: check-added-large-files
args: ['--maxkb=500']
- id: check-merge-conflict
- id: check-json
exclude: ^(submodules/|\.vscode/)
# === Tier 1: Plugin code formatting ===
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
files: ^[^/]+\.py$
args: ['--target-version', 'py310']
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
files: ^[^/]+\.py$
args: ['--profile', 'black']
# === Tier 1: Plugin code linting (manual stage) ===
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
files: ^[^/]+\.py$
args: ['--max-line-length=88', '--extend-ignore=E203,W503']
stages: [manual]
- repo: https://github.com/pycqa/bandit
rev: 1.7.5
hooks:
- id: bandit
files: ^[^/]+\.py$
args: ['-ll', '-i']
additional_dependencies: ['pbr']
stages: [manual]
# === Local hooks ===
- repo: local
hooks:
- id: plugin-syntax-check
name: Plugin Syntax Check
entry: python -m py_compile
language: system
files: ^[^/]+\.py$
types: [python]
- id: dockerfile-lint
name: Dockerfile Lint (hadolint)
entry: hadolint
language: system
files: ^Dockerfile
stages: [manual]