diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 8a719e0..502b6b4 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -21,11 +21,11 @@ jobs: with: python-version: 3.14 - name: Install dependencies - run: python -m pip install pre-commit + run: python -m pip install prek uv - name: Cache pre-commit environments uses: actions/cache@v5 with: - key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - path: ~/.cache/pre-commit + key: prek|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} + path: ~/.cache/prek - name: Run pre-commit hooks - run: pre-commit run -a --show-diff-on-failure --color=always + run: prek run -a --show-diff-on-failure --color=always diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5e1d2f6..776b611 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,8 @@ +# priorities: +# 0 - read-only +# 1000 - mutually non-conflicting fixers +# none - other fixers + # exclude vendored files exclude: '^(api/|demo/openseadragon-scalebar\.js)' @@ -6,51 +11,32 @@ repos: rev: v6.0.0 hooks: - id: check-added-large-files + priority: 0 - id: check-merge-conflict + priority: 0 - id: check-vcs-permalinks + priority: 0 - id: check-yaml + priority: 0 - id: end-of-file-fixer - id: fix-byte-order-marker - id: mixed-line-ending - id: trailing-whitespace - - repo: https://github.com/asottile/pyupgrade - rev: v3.21.2 - hooks: - - id: pyupgrade - name: Modernize Python code - args: ["--py313-plus"] - - - repo: https://github.com/PyCQA/isort - rev: 8.0.1 - hooks: - - id: isort - name: Reorder Python imports with isort - - - repo: https://github.com/psf/black - rev: 26.3.1 - hooks: - - id: black - name: Format Python code with black - - - repo: https://github.com/asottile/yesqa - rev: v1.5.0 - hooks: - - id: yesqa - additional_dependencies: [flake8-bugbear, Flake8-pyproject] - - - repo: https://github.com/PyCQA/flake8 - rev: 7.3.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.10 hooks: - - id: flake8 - name: Lint Python code with flake8 - additional_dependencies: [flake8-bugbear, Flake8-pyproject] + - id: ruff-check + types_or: [python, pyproject] + args: [--fix] + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.20.0 hooks: - id: mypy name: Check Python types + priority: 0 additional_dependencies: - boto3-stubs[s3] - types-Pillow @@ -63,16 +49,20 @@ repos: hooks: - id: codespell name: Check spelling with codespell + priority: 0 - repo: meta hooks: - id: check-hooks-apply + priority: 0 - id: check-useless-excludes + priority: 0 - repo: local hooks: - id: annotations name: Require "from __future__ import annotations" + priority: 0 language: pygrep types: [python] # Allow files with import statement, or of less than two characters. diff --git a/_testdata/testdata_fetch.py b/_testdata/testdata_fetch.py index 163a7d6..b6c0500 100755 --- a/_testdata/testdata_fetch.py +++ b/_testdata/testdata_fetch.py @@ -64,7 +64,7 @@ def fetch_file( sha.update(buf) count += len(buf) if count != int(r.headers['Content-Length']): - raise OSError(f"Short read fetching {relpath}") + raise OSError(f'Short read fetching {relpath}') if expected_sha256 is not None and expected_sha256 != sha.hexdigest(): raise OSError(f'Hash mismatch fetching {relpath}') except Exception: diff --git a/_testdata/testdata_index.py b/_testdata/testdata_index.py index 452ff16..2b9668d 100755 --- a/_testdata/testdata_index.py +++ b/_testdata/testdata_index.py @@ -45,7 +45,7 @@ ) OPTIONAL_FIELDS = frozenset(('credit',)) -INDEX_TEMPLATE = ''' +INDEX_TEMPLATE = """