forked from terrene-foundation/kailash-py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
164 lines (150 loc) · 6.16 KB
/
.pre-commit-config.yaml
File metadata and controls
164 lines (150 loc) · 6.16 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Pre-commit hooks configuration for Kailash Python SDK
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
# Black - Python code formatter
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
name: Format code with Black
description: "Run Black Python code formatter"
language_version: python3
args: [--line-length=88]
exclude: ^(data/outputs/|outputs/|examples/outputs/|docs/.*/_build/|_build/)
# isort - Python import sorter
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: Sort imports with isort
description: "Sort Python imports"
args: [--profile=black]
exclude: ^(data/outputs/|outputs/|examples/outputs/|docs/.*/_build/|_build/)
# Ruff - Python linter (replaces flake8, pylint, etc.)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
hooks:
- id: ruff
name: Lint with Ruff
description: "Run Ruff linter"
args: [--fix, --exit-non-zero-on-fix]
exclude: ^(data/outputs/|outputs/|examples/outputs/|docs/.*/_build/|_build/|examples/workflow_examples/)
# Built-in pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
name: Trim trailing whitespace
exclude: ^(data/outputs/|outputs/|examples/outputs/|docs/.*/_build/|_build/|.*\.html|.*_mermaid\.md)$
- id: end-of-file-fixer
name: Fix end of files
exclude: ^(data/outputs/|outputs/|examples/outputs/|docs/.*/_build/|_build/|.*\.html|.*_mermaid\.md)$
- id: check-yaml
name: Check YAML syntax
exclude: ^(data/outputs/|outputs/|examples/outputs/|docs/.*/_build/|_build/|packages/.*/deployment/kubernetes/.*\.yaml)$
- id: check-toml
name: Check TOML syntax
- id: check-json
name: Check JSON syntax
exclude: ^(data/outputs/|outputs/|examples/outputs/|docs/.*/_build/|_build/|.*node_modules/.*)$
- id: check-merge-conflict
name: Check for merge conflicts
- id: check-added-large-files
name: Check for large files
args: [--maxkb=1000]
exclude: ^(data/outputs/|outputs/|examples/outputs/|docs/.*/_build/|_build/)$
- id: debug-statements
name: Check for debug statements
# Python-specific checks
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-no-log-warn
name: Check for deprecated log.warn
- id: python-no-eval
name: Check for eval() usage
exclude: ^(src/kailash/nodes/transform/processors\.py|src/kailash/nodes/ai/ai_providers\.py|packages/kailash-kaizen/src/kaizen/nodes/ai/ai_providers\.py|src/kailash/api/mcp_integration\.py|tests/test_security/.*|examples/.*|src/kailash/nodes/logic/convergence\.py|src/kailash/nodes/logic/loop\.py|src/kailash/workflow/convergence\.py|src/kailash/workflow/cycle_builder\.py|src/kailash/workflow/cycle_config\.py|src/kailash/nodes/rag/agentic\.py|packages/kailash-kaizen/src/kaizen/nodes/rag/agentic\.py|src/kailash/runtime/local\.py|packages/kailash-nexus/src/nexus/auth/rate_limit/backends/redis\.py|tests/.*/(test_pythoncode_.*|test_security_.*|test_.*_security\.py|test_mcp_.*|test_ai\.py|test_.*_e2e\.py|test_.*_integration\.py|test_tpc_migration_.*\.py))$
- id: python-use-type-annotations
name: Require type annotations
- id: python-check-blanket-noqa
name: Check for blanket noqa
# Pytest - Run Tier 1 unit tests only
- repo: local
hooks:
- id: pytest-check
name: Run Tier 1 unit tests
entry: python -m pytest
language: system
args: [
tests/unit/, # Only unit tests
-m,
"not (slow or integration or e2e or requires_docker or requires_postgres or requires_mysql or requires_ollama)", # Exclude all external dependencies
--tb=short,
--maxfail=5,
--durations=10,
-x, # Stop on first failure
-q, # Quiet output
]
pass_filenames: false
always_run: true
stages: [pre-commit]
# Security scanning with Trivy (temporarily disabled due to config issues)
# - repo: local
# hooks:
# - id: trivy-fs
# name: Run Trivy filesystem scan
# entry: trivy
# language: system
# args: [
# filesystem,
# --security-checks=vuln,secret,config,
# --severity=HIGH,CRITICAL,
# --exit-code=1,
# --format=table,
# --quiet,
# .
# ]
# pass_filenames: false
# always_run: false
# stages: [pre-commit]
# Additional security checks (temporarily disabled due to version issues)
# - repo: https://github.com/Yelp/detect-secrets
# rev: v1.4.0
# hooks:
# - id: detect-secrets
# name: Detect secrets
# args: [--baseline, .secrets.baseline]
# exclude: ^(\.secrets\.baseline|tests/.*|.*\.lock)$
# Documentation checks
- repo: https://github.com/PyCQA/doc8
rev: v1.1.1
hooks:
- id: doc8
name: Check documentation style
args: [--max-line-length=100, --ignore=D001]
files: \.(rst|md)$
exclude: ^(data/outputs/|outputs/|examples/outputs/|docs/.*/_build/|_build/|.*_mermaid\.md)$
# Type checking with mypy (temporarily disabled due to type errors)
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.9.0
# hooks:
# - id: mypy
# name: Type check with mypy
# args: [--ignore-missing-imports, --no-strict-optional]
# exclude: ^(tests/|examples/|docs/|data/outputs/|outputs/)
# Configuration
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ""
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
autoupdate_schedule: weekly
skip: [pytest-check, trivy-fs] # Skip resource-intensive hooks in CI
submodules: false
# Default stages
default_stages: [pre-commit]
# Minimum pre-commit version
minimum_pre_commit_version: 3.0.0