diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..5de58d77d --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,48 @@ +--- +name: pre-commit +on: + pull_request: + push: + workflow_dispatch: +jobs: + pre-commit: + runs-on: ubuntu-latest + env: + RAW_LOG: pre-commit.log + CS_XML: pre-commit.xml + steps: + - run: sudo apt-get update && sudo apt-get install cppcheck uncrustify + if: false + - uses: actions/checkout@v4 + - run: python -m pip install pre-commit + - uses: actions/cache/restore@v4 + with: + path: ~/.cache/pre-commit/ + key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Run pre-commit hooks + env: + SKIP: no-commit-to-branch + run: | + set -o pipefail + pre-commit gc + pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} + - name: Convert Raw Log to Checkstyle format (launch action) + uses: mdeweerd/logToCheckStyle@v2025.1.1 + if: ${{ failure() }} + with: + in: ${{ env.RAW_LOG }} + # out: ${{ env.CS_XML }} + - uses: actions/cache/save@v4 + if: ${{ ! cancelled() }} + with: + path: ~/.cache/pre-commit/ + key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Provide log as artifact + uses: actions/upload-artifact@v4 + if: ${{ ! cancelled() }} + with: + name: precommit-logs + path: | + ${{ env.RAW_LOG }} + ${{ env.CS_XML }} + retention-days: 2 diff --git a/aider/coders/editblock_fenced_coder.py b/aider/coders/editblock_fenced_coder.py index 80e5036ea..cd09e27c5 100644 --- a/aider/coders/editblock_fenced_coder.py +++ b/aider/coders/editblock_fenced_coder.py @@ -5,5 +5,6 @@ from .editblock_fenced_prompts import EditBlockFencedPrompts class EditBlockFencedCoder(EditBlockCoder): """A coder that uses fenced search/replace blocks for code modifications.""" + edit_format = "diff-fenced" gpt_prompts = EditBlockFencedPrompts() diff --git a/aider/coders/help_coder.py b/aider/coders/help_coder.py index fcb1e6aa1..311805af7 100644 --- a/aider/coders/help_coder.py +++ b/aider/coders/help_coder.py @@ -5,6 +5,7 @@ from .help_prompts import HelpPrompts class HelpCoder(Coder): """Interactive help and documentation about aider.""" + edit_format = "help" gpt_prompts = HelpPrompts() diff --git a/aider/linter.py b/aider/linter.py index 51ed40b70..9c980366d 100644 --- a/aider/linter.py +++ b/aider/linter.py @@ -1,10 +1,11 @@ import os +import oslex import re +import shlex import subprocess import sys import traceback import warnings -import oslex from dataclasses import dataclass from pathlib import Path diff --git a/benchmark/refactor_tools.py b/benchmark/refactor_tools.py index 117770a67..03812b0c1 100755 --- a/benchmark/refactor_tools.py +++ b/benchmark/refactor_tools.py @@ -132,7 +132,7 @@ def find_non_self_methods(path): with open(filename, "r") as file: try: node = ast.parse(file.read(), filename=filename) - except: + except: # noqa: E722 pass checker = SelfUsageChecker() checker.visit(node) diff --git a/pyproject.toml b/pyproject.toml index f7b25eee8..928c5fee2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,5 +48,5 @@ build-backend = "setuptools.build_meta" write_to = "aider/_version.py" [tool.codespell] -skip = "*.svg,Gemfile.lock" +skip = "*.svg,Gemfile.lock,tests/fixtures/*,aider/website/*" write-changes = true diff --git a/scripts/30k-image.py b/scripts/30k-image.py index 9a62206e4..29924d424 100644 --- a/scripts/30k-image.py +++ b/scripts/30k-image.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# flake8: noqa: E501 """ Generate a celebratory SVG image for Aider reaching 30,000 GitHub stars. This creates a shareable social media graphic with confetti animation. @@ -7,7 +8,6 @@ This creates a shareable social media graphic with confetti animation. import argparse import base64 import math -import os import random from pathlib import Path diff --git a/scripts/dl_icons.py b/scripts/dl_icons.py index 8240ca641..7d878c907 100644 --- a/scripts/dl_icons.py +++ b/scripts/dl_icons.py @@ -3,7 +3,6 @@ Download Material Design Icons SVGs used in the README and save to local assets. """ -import os from pathlib import Path import requests diff --git a/scripts/redact-cast.py b/scripts/redact-cast.py index 91f230e87..c7a1e4ea8 100755 --- a/scripts/redact-cast.py +++ b/scripts/redact-cast.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 import json -import os -import re import sys import pyte diff --git a/tests/basic/test_watch.py b/tests/basic/test_watch.py index 524f80e08..16e4f8206 100644 --- a/tests/basic/test_watch.py +++ b/tests/basic/test_watch.py @@ -155,7 +155,7 @@ def test_ai_comment_pattern(): assert ( question_js_has_bang == "?" ), "Expected at least one bang (!) comment in watch_question.js fixture" - + # Test Lisp fixture lisp_path = fixtures_dir / "watch.lisp" lisp_lines, lisp_comments, lisp_has_bang = watcher.get_ai_comments(str(lisp_path))