From 327685ffe1d02ba2457d040e853d830174b3c8fe Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 16 Dec 2025 09:56:16 -0500 Subject: [PATCH 1/5] feat: enforce files end with single newline via super-linter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add EditorConfig configuration to ensure all files end with a single newline character and trim trailing whitespace. Enable VALIDATE_EDITORCONFIG in super-linter workflow to enforce these rules in CI. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .editorconfig | 8 ++++++++ .github/workflows/check.yaml | 1 + 2 files changed, 9 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..8656ddcd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 5cf88ad0..276a96bd 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -123,3 +123,4 @@ jobs: # https://github.com/super-linter/super-linter/blob/main/docs/run-linter-locally.md#share-environment-variables-between-environments VALIDATE_ALL_CODEBASE: false VALIDATE_MARKDOWN: true + VALIDATE_EDITORCONFIG: true From e1b4c622b9791789fe4c32e9680505d6da76c89f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 16 Dec 2025 10:05:13 -0500 Subject: [PATCH 2/5] feat: add pre-commit hooks for file formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add pre-commit configuration with hooks to: - Ensure all files end with single newline (end-of-file-fixer) - Remove trailing whitespace (trailing-whitespace) - Validate YAML and TOML syntax - Prevent merge conflict markers Integrate with existing hatch workflow and add CI job. Include setup instructions in CLAUDE.md. Applied automatic formatting fixes to existing files. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .containerignore | 2 +- .editorconfig | 2 +- .github/workflows/check.yaml | 21 +++++++++++++++++++ .pre-commit-config.yaml | 10 +++++++++ AGENTS.md | 19 ++++++++++++++++- docs/concepts/index.rst | 1 - .../0001-rust-version.patch | 2 +- docs/how-tos/pyproject-overrides.rst | 12 +++++------ e2e/bootstrap_extras.txt | 2 +- e2e/build-parallel/graph.json | 2 +- e2e/changelog_settings-2/stevedore.yaml | 1 - e2e/changelog_settings/stevedore.yaml | 1 - .../flit_core/flit_core.patch | 2 +- e2e/graph-with-dependency-conflict.json | 2 +- e2e/migrate_graph/old_graph.json | 2 +- e2e/setup_coverage.py | 12 +++++------ e2e/test_bootstrap_parallel_git_url.sh | 1 - e2e/test_bootstrap_parallel_git_url_tag.sh | 1 - e2e/test_bootstrap_prerelease.sh | 2 +- e2e/test_migrate_graph.sh | 2 +- e2e/validate_inputs/invalid-constraints.txt | 4 ++-- .../invalid-duplicate-constraints.txt | 2 +- e2e/validate_inputs/invalid-requirements.txt | 2 +- e2e/validate_inputs/requirements.txt | 1 - .../valid-duplicate-constraints.txt | 2 +- pyproject.toml | 5 ++++- 26 files changed, 80 insertions(+), 35 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.containerignore b/.containerignore index 40331ad9..53b75be3 100644 --- a/.containerignore +++ b/.containerignore @@ -12,4 +12,4 @@ build-logs/* sdists-repo/* venv* wheels-repo/* -work-dir*/* \ No newline at end of file +work-dir*/* diff --git a/.editorconfig b/.editorconfig index 8656ddcd..0eb186f9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,4 +5,4 @@ insert_final_newline = true trim_trailing_whitespace = true [*.md] -trim_trailing_whitespace = false \ No newline at end of file +trim_trailing_whitespace = false diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 276a96bd..24889996 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -5,6 +5,27 @@ on: - pull_request jobs: + pre-commit: + name: pre-commit + runs-on: ubuntu-latest + if: ${{ !startsWith(github.ref, 'refs/tags') }} + + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.11" # minimum supported lang version + + - name: Install dependencies + run: python -m pip install hatch 'click!=8.3.0' + + - name: Run pre-commit hooks + run: hatch run lint:install-hooks && hatch run lint:check + linter: name: linter runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..c7852452 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: end-of-file-fixer # Ensures single trailing newline + - id: trailing-whitespace # Removes trailing spaces + args: [--markdown-linebreak-ext=md] # Preserve markdown line breaks + - id: check-yaml # Validates YAML syntax + - id: check-merge-conflict # Prevents merge conflict markers + - id: check-toml # Validates TOML syntax diff --git a/AGENTS.md b/AGENTS.md index 7d2ed64a..cf8efee5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,6 +36,13 @@ ## Commands (IMPORTANT: Use File-Scoped First) +### Setup Commands (Run Once) + +```bash +# Install pre-commit hooks for automatic file formatting +hatch run lint:install-hooks +``` + ### File-Scoped Commands (PREFER THESE) ```bash @@ -61,9 +68,19 @@ hatch run test:test --log-level DEBUG hatch run lint:fix # Format all code hatch run test:test # Full test suite (slow!) hatch run mypy:check # Type check everything -hatch run lint:check # Final lint check +hatch run lint:check # Final lint check (includes pre-commit hooks) ``` +### Pre-commit Hooks + +The project uses pre-commit hooks to automatically check file formatting: +- **File endings**: Ensures all files end with a single newline +- **Whitespace**: Removes trailing whitespace +- **Syntax**: Validates YAML/TOML files +- **Conflicts**: Prevents committing merge conflict markers + +These run automatically on commit if installed with `hatch run lint:install-hooks`. + ## Safety and Permissions ### Allowed Without Asking diff --git a/docs/concepts/index.rst b/docs/concepts/index.rst index 5cd4535b..23cc2c9b 100644 --- a/docs/concepts/index.rst +++ b/docs/concepts/index.rst @@ -5,4 +5,3 @@ Concepts :maxdepth: 1 dependencies - diff --git a/docs/example/overrides/patches/pydantic_core-2.18.4/0001-rust-version.patch b/docs/example/overrides/patches/pydantic_core-2.18.4/0001-rust-version.patch index b8ab8581..f382fa41 100644 --- a/docs/example/overrides/patches/pydantic_core-2.18.4/0001-rust-version.patch +++ b/docs/example/overrides/patches/pydantic_core-2.18.4/0001-rust-version.patch @@ -11,6 +11,6 @@ ] -rust-version = "1.76" +rust-version = "1.75" - + [dependencies] pyo3 = { version = "0.21.2", features = ["generate-import-lib", "num-bigint"] } diff --git a/docs/how-tos/pyproject-overrides.rst b/docs/how-tos/pyproject-overrides.rst index ff143650..683f7776 100644 --- a/docs/how-tos/pyproject-overrides.rst +++ b/docs/how-tos/pyproject-overrides.rst @@ -1,15 +1,15 @@ Working with Complex pyproject.toml Requirements ================================================ -When using fromager's ``project_override`` feature (documented in the +When using fromager's ``project_override`` feature (documented in the :doc:`../customization` guide), there are some advanced scenarios worth understanding for complex build requirements. Handling Multiple Requirements for the Same Package --------------------------------------------------- -When applying overrides, requirements are matched by (canonical) name, so updating -``numpy`` will affect all numpy requirements - all existing ones are replaced by +When applying overrides, requirements are matched by (canonical) name, so updating +``numpy`` will affect all numpy requirements - all existing ones are replaced by the new requirements from the override, whether that's just one or multiple. Consider a ``pyproject.toml`` with multiple version-specific numpy requirements: @@ -43,7 +43,7 @@ All existing numpy requirements are replaced by the single new one: [build-system] requires = [ - "numpy==2.0.0", + "numpy==2.0.0", "packaging", "setuptools==59.2.0; python_version<'3.12'", "setuptools<70.0.0; python_version>='3.12'" @@ -58,7 +58,7 @@ When you apply overrides with multiple new numpy requirements: project_override: update_build_requires: - - setuptools + - setuptools - numpy<3.0.0; python_version=='3.12' - numpy==3.0.0; python_version>'3.12' @@ -72,4 +72,4 @@ All existing numpy requirements are replaced by all the new numpy requirements: "numpy==3.0.0; python_version>'3.12'", "packaging", "setuptools" - ] \ No newline at end of file + ] diff --git a/e2e/bootstrap_extras.txt b/e2e/bootstrap_extras.txt index a55f00e0..a8d47daa 100644 --- a/e2e/bootstrap_extras.txt +++ b/e2e/bootstrap_extras.txt @@ -1,2 +1,2 @@ requests[socks]==2.32.3 -stevedore ; python_version < "3.7" # should not be included in output of test \ No newline at end of file +stevedore ; python_version < "3.7" # should not be included in output of test diff --git a/e2e/build-parallel/graph.json b/e2e/build-parallel/graph.json index b0b01c50..03573c96 100644 --- a/e2e/build-parallel/graph.json +++ b/e2e/build-parallel/graph.json @@ -308,4 +308,4 @@ } ] } -} \ No newline at end of file +} diff --git a/e2e/changelog_settings-2/stevedore.yaml b/e2e/changelog_settings-2/stevedore.yaml index 88dbc813..02f406f4 100644 --- a/e2e/changelog_settings-2/stevedore.yaml +++ b/e2e/changelog_settings-2/stevedore.yaml @@ -2,4 +2,3 @@ changelog: "5.2.0": - test 1 - test 2 - diff --git a/e2e/changelog_settings/stevedore.yaml b/e2e/changelog_settings/stevedore.yaml index 24460789..dc16b165 100644 --- a/e2e/changelog_settings/stevedore.yaml +++ b/e2e/changelog_settings/stevedore.yaml @@ -1,4 +1,3 @@ changelog: "5.2.0": - test 1 - \ No newline at end of file diff --git a/e2e/flit_core_patches/flit_core/flit_core.patch b/e2e/flit_core_patches/flit_core/flit_core.patch index 87339758..cf36d894 100644 --- a/e2e/flit_core_patches/flit_core/flit_core.patch +++ b/e2e/flit_core_patches/flit_core/flit_core.patch @@ -3,7 +3,7 @@ index 8ba0a83..0ae0786 100644 --- a/README.rst +++ b/README.rst @@ -7,3 +7,5 @@ interface is the API specified by PEP 517, at ``flit_core.buildapi``. - + See the `Flit documentation `_ for more information. + diff --git a/e2e/graph-with-dependency-conflict.json b/e2e/graph-with-dependency-conflict.json index d5c28216..e362671b 100644 --- a/e2e/graph-with-dependency-conflict.json +++ b/e2e/graph-with-dependency-conflict.json @@ -9113,4 +9113,4 @@ } ] } -} \ No newline at end of file +} diff --git a/e2e/migrate_graph/old_graph.json b/e2e/migrate_graph/old_graph.json index a52b195e..8b6f700d 100644 --- a/e2e/migrate_graph/old_graph.json +++ b/e2e/migrate_graph/old_graph.json @@ -5701,4 +5701,4 @@ "setuptools>=40.8.0" ] ] - } \ No newline at end of file + } diff --git a/e2e/setup_coverage.py b/e2e/setup_coverage.py index b9b2010b..6f11b3f6 100644 --- a/e2e/setup_coverage.py +++ b/e2e/setup_coverage.py @@ -9,26 +9,26 @@ def setup_coverage() -> None: """Create coverage.pth file for subprocess coverage collection.""" # Get the virtual environment root venv_root = pathlib.Path(sys.prefix) - + # Find site-packages directory site_packages_dirs = [pathlib.Path(p) for p in site.getsitepackages()] - + # Find the one that's in our virtual environment site_packages = None for sp in site_packages_dirs: if str(sp).startswith(str(venv_root)): site_packages = sp break - + if not site_packages: site_packages = site_packages_dirs[0] # fallback - + # Create coverage.pth file cov_pth = site_packages / "cov.pth" cov_pth.parent.mkdir(parents=True, exist_ok=True) cov_pth.write_text("import coverage; coverage.process_startup()") - + print(f"Coverage setup complete: {cov_pth}") if __name__ == "__main__": - setup_coverage() + setup_coverage() diff --git a/e2e/test_bootstrap_parallel_git_url.sh b/e2e/test_bootstrap_parallel_git_url.sh index b575fced..09361ec2 100755 --- a/e2e/test_bootstrap_parallel_git_url.sh +++ b/e2e/test_bootstrap_parallel_git_url.sh @@ -57,4 +57,3 @@ $pass twine check "$OUTDIR"/sdists-repo/builds/*.tar.gz twine check "$OUTDIR"/wheels-repo/downloads/*.whl - diff --git a/e2e/test_bootstrap_parallel_git_url_tag.sh b/e2e/test_bootstrap_parallel_git_url_tag.sh index b4e4180b..0de75ca2 100755 --- a/e2e/test_bootstrap_parallel_git_url_tag.sh +++ b/e2e/test_bootstrap_parallel_git_url_tag.sh @@ -57,4 +57,3 @@ $pass twine check "$OUTDIR"/sdists-repo/builds/*.tar.gz twine check "$OUTDIR"/wheels-repo/downloads/*.whl - diff --git a/e2e/test_bootstrap_prerelease.sh b/e2e/test_bootstrap_prerelease.sh index 46682ed5..c650db0a 100755 --- a/e2e/test_bootstrap_prerelease.sh +++ b/e2e/test_bootstrap_prerelease.sh @@ -46,4 +46,4 @@ if ! grep -q "flit_core: new toplevel dependency flit_core<2.0.1 resolves to 2.0 pass=false fi -$pass \ No newline at end of file +$pass diff --git a/e2e/test_migrate_graph.sh b/e2e/test_migrate_graph.sh index 8b951b2c..fd641e39 100755 --- a/e2e/test_migrate_graph.sh +++ b/e2e/test_migrate_graph.sh @@ -17,4 +17,4 @@ if [ $? -ne 0 ]; then pass=false fi; -$pass \ No newline at end of file +$pass diff --git a/e2e/validate_inputs/invalid-constraints.txt b/e2e/validate_inputs/invalid-constraints.txt index d835c869..437d4d1d 100644 --- a/e2e/validate_inputs/invalid-constraints.txt +++ b/e2e/validate_inputs/invalid-constraints.txt @@ -1,3 +1,3 @@ -# This constraints file is invalid on purpose to test the lint-requirements +# This constraints file is invalid on purpose to test the lint-requirements # command of fromager. Do not attempt to fix this file -vllm[tensorizer]==0.9.4 \ No newline at end of file +vllm[tensorizer]==0.9.4 diff --git a/e2e/validate_inputs/invalid-duplicate-constraints.txt b/e2e/validate_inputs/invalid-duplicate-constraints.txt index 43ddff9f..5e60713f 100644 --- a/e2e/validate_inputs/invalid-duplicate-constraints.txt +++ b/e2e/validate_inputs/invalid-duplicate-constraints.txt @@ -1,4 +1,4 @@ -# This requirements file contains duplicates entries on purpose +# This requirements file contains duplicates entries on purpose # to test the lint-requirements. Do not attempt to fix this file stevedore==5.2.0; platform_machine == 'ppc64le' kfp==2.11.0 diff --git a/e2e/validate_inputs/invalid-requirements.txt b/e2e/validate_inputs/invalid-requirements.txt index cbfb06de..38d52fb5 100644 --- a/e2e/validate_inputs/invalid-requirements.txt +++ b/e2e/validate_inputs/invalid-requirements.txt @@ -1,4 +1,4 @@ -# This requirements file is invalid on purpose to test the lint-requirements +# This requirements file is invalid on purpose to test the lint-requirements # command of fromager. Do not attempt to fix this file foo== diff --git a/e2e/validate_inputs/requirements.txt b/e2e/validate_inputs/requirements.txt index ffdab955..30d0c508 100644 --- a/e2e/validate_inputs/requirements.txt +++ b/e2e/validate_inputs/requirements.txt @@ -2,4 +2,3 @@ # command of fromager and contains examples of packages stevedore==5.2.0 kfp==2.11.0 - diff --git a/e2e/validate_inputs/valid-duplicate-constraints.txt b/e2e/validate_inputs/valid-duplicate-constraints.txt index 2bbeec3d..6f54e014 100644 --- a/e2e/validate_inputs/valid-duplicate-constraints.txt +++ b/e2e/validate_inputs/valid-duplicate-constraints.txt @@ -1,4 +1,4 @@ -# This requirements file contains duplicates entries on purpose +# This requirements file contains duplicates entries on purpose # to test the lint-requirements. Do not attempt to fix this file stevedore==5.2.0; platform_machine != 'ppc64le' kfp==2.11.0 diff --git a/pyproject.toml b/pyproject.toml index e1c8e919..934310fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -236,18 +236,21 @@ features = ["build"] dependencies = [ "ruff", "packaging", - "check-python-versions" + "check-python-versions", + "pre-commit" ] [tool.hatch.envs.lint.scripts] check = [ "ruff check src tests", "ruff format --check src tests", "python ./e2e/mergify_lint.py", + "pre-commit run --all-files", ] fix = [ "ruff format src tests docs", "ruff check --fix src tests docs", ] +install-hooks = "pre-commit install" pkglint = [ "python -m build", "twine check dist/*.tar.gz dist/*.whl", From 3496335c95730a61d3c6ffd0640f1ded9984fdbb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 16 Dec 2025 10:14:31 -0500 Subject: [PATCH 3/5] feat: integrate hatch lint and mypy checks into pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add local hooks to run hatch lint:check and mypy:check as part of pre-commit workflow, ensuring comprehensive code quality checks before commits. Add separate 'precommit' hatch script to manually run pre-commit hooks without circular dependency. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/check.yaml | 2 +- .pre-commit-config.yaml | 16 ++++++++++++++++ pyproject.toml | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 24889996..2dd39e97 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -24,7 +24,7 @@ jobs: run: python -m pip install hatch 'click!=8.3.0' - name: Run pre-commit hooks - run: hatch run lint:install-hooks && hatch run lint:check + run: hatch run lint:install-hooks && hatch run lint:precommit linter: name: linter diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c7852452..680756d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,3 +8,19 @@ repos: - id: check-yaml # Validates YAML syntax - id: check-merge-conflict # Prevents merge conflict markers - id: check-toml # Validates TOML syntax + + - repo: local + hooks: + - id: hatch-lint + name: hatch lint check + entry: hatch run lint:check + language: system + types: [python] + pass_filenames: false + + - id: hatch-mypy + name: hatch mypy check + entry: hatch run mypy:check + language: system + types: [python] + pass_filenames: false diff --git a/pyproject.toml b/pyproject.toml index 934310fb..b96a9004 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -244,12 +244,12 @@ check = [ "ruff check src tests", "ruff format --check src tests", "python ./e2e/mergify_lint.py", - "pre-commit run --all-files", ] fix = [ "ruff format src tests docs", "ruff check --fix src tests docs", ] +precommit = "pre-commit run --all-files" install-hooks = "pre-commit install" pkglint = [ "python -m build", From 87778b1f7dd0c797cb399ec5b23381824e6c29b2 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 16 Dec 2025 11:12:27 -0500 Subject: [PATCH 4/5] fix: clean up old pre-commit implementation Remove the old pre-commit script and rely instead on the pre-commit command to run the linters. Update the documentation to reflect the change in how the hook should be configured. --- AGENTS.md | 11 ++++++---- CONTRIBUTING.md | 16 +++++++-------- scripts/pre-commit | 26 ------------------------ scripts/setup-pre-commit-hook.sh | 35 -------------------------------- 4 files changed, 14 insertions(+), 74 deletions(-) delete mode 100755 scripts/pre-commit delete mode 100755 scripts/setup-pre-commit-hook.sh diff --git a/AGENTS.md b/AGENTS.md index cf8efee5..e7b2984b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -65,19 +65,22 @@ hatch run test:test --log-level DEBUG ### Project-Wide Commands (ASK BEFORE RUNNING) ```bash -hatch run lint:fix # Format all code -hatch run test:test # Full test suite (slow!) -hatch run mypy:check # Type check everything -hatch run lint:check # Final lint check (includes pre-commit hooks) +hatch run lint:fix # Format all code +hatch run test:test # Full test suite (slow!) +hatch run mypy:check # Type check everything +hatch run lint:check # Final lint check +hatch run lint:precommit # All linters and other pre-commit hooks ``` ### Pre-commit Hooks The project uses pre-commit hooks to automatically check file formatting: + - **File endings**: Ensures all files end with a single newline - **Whitespace**: Removes trailing whitespace - **Syntax**: Validates YAML/TOML files - **Conflicts**: Prevents committing merge conflict markers +- **Linters**: Runs the `mypy` and `ruff` linters These run automatically on commit if installed with `hatch run lint:install-hooks`. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e19cc97c..efe85384 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,8 +45,8 @@ git remote add upstream https://github.com/python-wheel-build/fromager.git # 4. Create development environment hatch env create -# 5. Install pre-commit hook (optional but recommended) -./scripts/setup-pre-commit-hook.sh +# 5. Install pre-commit hooks (optional but recommended) +hatch run lint:install-hooks ``` ### Contribution Workflow @@ -64,7 +64,7 @@ git checkout -b feat/ hatch run test:test tests/test_.py # Test your specific changes # 4. Before committing, run full quality checks -hatch run lint:fix && hatch run test:test && hatch run mypy:check && hatch run lint:check +hatch run lint:precommit # 5. Commit using Conventional Commits git commit -m "feat(scope): short summary" @@ -81,18 +81,16 @@ To ensure quality checks run automatically before each commit, install the pre-c ```bash # Install the pre-commit hook (run once after cloning) -./scripts/setup-pre-commit-hook.sh +hatch run lint:install-hooks -# The hook automatically runs before each commit: -# - hatch run lint:check -# - hatch run mypy:check +# The hook automatically runs a selection of linters before each commit. # If the hook fails, it will prevent the commit and show helpful messages -# You can fix issues automatically with: +# You can fix some issues automatically with: hatch run lint:fix ``` -The pre-commit hook prevents commits that would fail CI quality checks, saving time and ensuring consistent code quality. +The pre-commit hook prevents commits that would fail some CI quality checks, saving time and ensuring consistent code quality. --- diff --git a/scripts/pre-commit b/scripts/pre-commit deleted file mode 100755 index 60dc7c14..00000000 --- a/scripts/pre-commit +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -# -# Git pre-commit hook to run quality checks -# This ensures all commits pass linting and type checking -# - -set -e # Exit immediately if any command fails - -echo "Running pre-commit checks..." - -# Run lint check -echo "🔍 Running lint check..." -if ! hatch run lint:check; then - echo "❌ Lint check failed. Please fix linting issues and try again." - echo " You can run 'hatch run lint:fix' to automatically fix many issues." - exit 1 -fi - -# Run mypy type checking -echo "🔍 Running mypy type check..." -if ! hatch run mypy:check; then - echo "❌ MyPy type check failed. Please fix type annotations and try again." - exit 1 -fi - -echo "✅ All pre-commit checks passed!" \ No newline at end of file diff --git a/scripts/setup-pre-commit-hook.sh b/scripts/setup-pre-commit-hook.sh deleted file mode 100755 index 41263bed..00000000 --- a/scripts/setup-pre-commit-hook.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# -# Setup script to install the pre-commit hook for fromager development -# -# This script copies the pre-commit hook to .git/hooks/ and makes it executable -# - -set -e - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" -HOOKS_DIR="$REPO_ROOT/.git/hooks" -PRE_COMMIT_HOOK="$HOOKS_DIR/pre-commit" - -echo "🔧 Setting up pre-commit hook for fromager..." - -# Check if we're in a git repository -if [ ! -d "$HOOKS_DIR" ]; then - echo "❌ Error: Not in a git repository or .git/hooks directory not found" - exit 1 -fi - -# Copy the pre-commit hook script -cp "$SCRIPT_DIR/pre-commit" "$PRE_COMMIT_HOOK" - -# Make it executable -chmod +x "$PRE_COMMIT_HOOK" - -echo "✅ Pre-commit hook installed successfully!" -echo "" -echo "The hook will now run 'hatch run lint:check' and 'hatch run mypy:check'" -echo "before every commit to ensure code quality." -echo "" -echo "To bypass the hook for a specific commit (not recommended):" -echo " git commit --no-verify -m \"message\"" \ No newline at end of file From d7437f310114e6ef5c5d55b32e84697aeb50e80d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 16 Dec 2025 11:17:33 -0500 Subject: [PATCH 5/5] fix: add charset specification to .editorconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add explicit utf-8 charset to fix super-linter EditorConfig validation error complaining about "Ascii" instead of "" encoding. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/.editorconfig b/.editorconfig index 0eb186f9..9b9f51f3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,7 @@ root = true [*] +charset = utf-8 insert_final_newline = true trim_trailing_whitespace = true