Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 127 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Canonical pre-commit configuration - identical across all repositories and branches.
# Managed by gvatsal60/.github; keep in sync when hooks are added or upgraded.
repos:
# Syncs pre-commit dependencies with the latest versions.
- repo: https://github.com/mxr/sync-pre-commit-deps
Expand All @@ -9,25 +11,110 @@ repos:
rev: "v6.0.0"
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
exclude: '\.ipynb$' # Exclude Jupyter notebooks
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
args: [--allow-multiple-documents] # Allow multi-document YAML streams
- id: debug-statements
- id: destroyed-symlinks
# - id: detect-aws-credentials
- id: detect-private-key
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: name-tests-test
- id: pretty-format-json
args: [--autofix]
exclude: '\.ipynb$' # Exclude Jupyter notebooks
- id: requirements-txt-fixer
- id: trailing-whitespace
# Ruff for linting and formatting Python files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.16.9"
hooks:
- id: ruff-check
args: [--fix, --unsafe-fixes]
- id: ruff-format

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Five overlapping auto-fixers now run on the same Python files in one pre-commit pass

ruff-check --fix --unsafe-fixes (line 47), ruff-format (49), pyupgrade (63), autopep8 (68) and isort (74) all mutate the same files. pre-commit aborts the run as soon as a hook rewrites a file, and these tools do not agree by default (autopep8 reformats what ruff-format produced, isort and ruff's I001 rules sort differently), so every commit touching Python can need several manual re-commit rounds and may never settle.

Recommendation: keep a single formatter (ruff-format) plus one import sorter, and move the redundant fixers (autopep8, pyupgrade, isort) to their own opt-in config rather than the canonical shared file.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

# Uses pygrep to enforce Python type annotations.
- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: python-use-type-annotations
# Runs mypy to check Python type annotations.
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v2.3.1"
hooks:
- id: mypy
# Pyupgrade for modernizing Python syntax
- repo: https://github.com/asottile/pyupgrade
rev: "v3.21.2"
hooks:
- id: pyupgrade
# Autopep8 for auto-formatting Python code
- repo: https://github.com/hhatto/autopep8
rev: "v2.3.2"
hooks:
- id: autopep8
# Isort for sorting Python imports
- repo: https://github.com/pycqa/isort
rev: "9.0.2"
hooks:
- id: isort
# Flake8 for linting Python files
- repo: https://github.com/pycqa/flake8
rev: "7.4.1"
hooks:
- id: flake8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: flake8 defaults conflict with ruff-format (79 vs 88 columns)

ruff-format formats to a 88-character line length, while flake8 with no arguments and no config file (there is no setup.cfg, tox.ini, or .flake8 in this repository) reports E501 for any line longer than 79 characters. In any repository that contains Python files this makes the newly added flake8 hook fail on code that ruff-format just produced, so the two hooks can never both pass.

Either pin them to the same width, e.g.

      - id: flake8
        args: [--max-line-length=88]

or drop flake8 from the canonical set since ruff-check already covers most of what it reports.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

# Clang-format for formatting C, C++, and JavaScript files
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v23.1.1"
hooks:
- id: clang-format
# ESLint for linting JavaScript and TypeScript files
- repo: https://github.com/pre-commit/mirrors-eslint
rev: "v10.11.0"
hooks:
- id: eslint
# Lints SCSS files to enforce style and best practices.
- repo: https://github.com/pre-commit/mirrors-scss-lint
rev: "v0.60.0"
hooks:
- id: scss-lint
# Runs JSHint to analyze JavaScript code for potential errors.
- repo: https://github.com/pre-commit/mirrors-jshint
rev: "v2.13.6"
hooks:
- id: jshint
# Uses fixmyjs to automatically fix simple JavaScript issues.
- repo: https://github.com/pre-commit/mirrors-fixmyjs
rev: "v2.0.0"
hooks:
- id: fixmyjs
# Runs CSSLint to check CSS files for errors and stylistic issues.
- repo: https://github.com/pre-commit/mirrors-csslint
rev: "v1.0.5"
hooks:
- id: csslint
# Nbstripout for stripping output from Jupyter Notebooks
- repo: https://github.com/kynan/nbstripout
rev: "0.9.1"
hooks:
- id: nbstripout
# shfmt hook for formatting shell scripts
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.14.1-1
rev: "v3.14.1-1"
hooks:
- id: shfmt
name: shfmt
Expand All @@ -50,6 +137,11 @@ repos:
entry: bashate
language: python
types: [shell]
# Actionlint for linting GitHub Actions YAML files
- repo: https://github.com/rhysd/actionlint
rev: "v1.7.12"
hooks:
- id: actionlint
# Yamlfmt for formatting YAML files
- repo: https://github.com/google/yamlfmt
rev: "v0.21.0"
Expand All @@ -60,9 +152,42 @@ repos:
rev: "v2.4.3"
hooks:
- id: codespell
# Checkmake for linting Makefiles
- repo: https://github.com/mrtazz/checkmake
rev: "v0.3.2"
hooks:
- id: checkmake
# SQLFluff for linting and fixing SQL files
- repo: https://github.com/sqlfluff/sqlfluff
rev: "4.3.0"
hooks:
- id: sqlfluff-lint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: sqlfluff will error out because no dialect is configured

Neither hook here passes --dialect, and this repository has no .sqlfluff config file. sqlfluff refuses to lint a file without a dialect and exits non-zero with No dialect was specified, so the moment a .sql file is added (and this config is being rolled out fleet-wide, so some of the target repositories do have SQL), both sqlfluff-lint and sqlfluff-fix fail instead of reporting lint violations.

Add a repository-level .sqlfluff, or pass the dialect explicitly:

      - id: sqlfluff-lint
        args: [--dialect, ansi]

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

- id: sqlfluff-fix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Run sqlfluff-fix before sqlfluff-lint

pre-commit executes hooks in declaration order, so linting happens against the unfixed sources and every violation that the fixer would have resolved still fails the run, forcing an unnecessary re-commit. Swapping the two ids makes the fix land first and the lint pass verify the result.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

# RuboCop for linting Ruby files
- repo: https://github.com/rubocop/rubocop
rev: "v1.91.0"
hooks:
- id: rubocop
# Terraform-py for formatting and validating Terraform files
- repo: https://github.com/AleksaC/terraform-py
rev: "v1.16.4"
hooks:
- id: tf-fmt
- id: tf-validate
# Gitleaks for detecting secrets in Git repositories
- repo: https://github.com/gitleaks/gitleaks
rev: "v8.30.1"
hooks:
- id: gitleaks
# Talisman for pre-commit Git hooks to detect sensitive files
- repo: https://github.com/thoughtworks/talisman
rev: "v1.37.0"
hooks:
- id: talisman-commit
entry: cmd --githook pre-commit
# Markdownlint for linting Markdown files
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.23.3
rev: "v0.23.3"
hooks:
- id: markdownlint-cli2
args: [--fix]
Loading