diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 40e8b3c7..e67cb051 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -83,10 +83,10 @@ jobs: ~/.nox .nox key: - ${{ runner.os }}-nox-${{ matrix.session.session }}-${{ env.pythonLocation }}-${{ + ${{ runner.os }}-nox-v2-${{ matrix.session.session }}-${{ env.pythonLocation }}-${{ hashFiles('**/uv.lock') }}-${{ hashFiles('**/noxfile.py') }} restore-keys: | - ${{ runner.os }}-nox-${{ matrix.session.session }}-${{ env.pythonLocation }} + ${{ runner.os }}-nox-v2-${{ matrix.session.session }}-${{ env.pythonLocation }} - name: Setup mise uses: jdx/mise-action@146a28175021df8ca24f8ee1828cc2a60f980bd5 # v3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1d39518c..40cd65cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,35 +52,41 @@ repos: types: [ python ] args: [ "--py310-plus" ] - - repo: https://github.com/provinzkraut/unasyncd - rev: v0.9.0 + - repo: local hooks: - id: unasyncd - additional_dependencies: [ "ruff" ] + name: unasyncd + entry: uv run unasyncd + language: system + types: [ python ] + pass_filenames: false + require_serial: true - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.13.0 + - repo: local hooks: - - id: ruff-check - types_or: [ python, pyi ] - args: [ --fix ] - - id: ruff-format - types_or: [ python, pyi ] + - id: ruff + name: ruff + entry: tools/mise run ruff:pre-commit + language: system + types: [ python ] + pass_filenames: false + require_serial: true - repo: local hooks: - id: lint name: lint - entry: mise run lint:pre-commit - language: python + entry: tools/mise run lint:pre-commit + language: system types: [ python ] + pass_filenames: false require_serial: true - repo: local hooks: - id: task-docs name: Tasks documentation - entry: mise run render:usage + entry: tools/mise run render:usage language: system files: ^mise.toml$ pass_filenames: false diff --git a/mise.toml b/mise.toml index cc0d28d2..b7bd1852 100644 --- a/mise.toml +++ b/mise.toml @@ -191,6 +191,10 @@ run = "uv run nox --json -t tests -l | jq 'map(.name) | unique'" description = "Check ruff formatting" run = "uv run ruff check" +[tasks."ruff:pre-commit"] +description = "Fix ruff errors and format (for pre-commit)" +run = ["uv run ruff check --fix", "uv run ruff format"] + [tasks."ruff:fix"] description = "Fix ruff errors" run = "uv run ruff check --fix --unsafe-fixes" @@ -256,4 +260,4 @@ run = [ [tasks."render:usage"] description = "Generate tasks documentation" -run = ["mise generate task-docs > tasks.md"] +run = ["tools/mise generate task-docs > tasks.md"] diff --git a/pyproject.toml b/pyproject.toml index 27e13d2e..c3a3ca1c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,7 +63,7 @@ dev = [ ] codeflash = ["codeflash"] doc = ["git-cliff>=2.6.1"] -lint = ["basedpyright", "ruff", "vulture", "slotscheck>=0.16.5"] +lint = ["basedpyright", "ruff>=0.14.10,<0.15", "vulture", "slotscheck>=0.16.5"] mysql = ["asyncmy", "cryptography"] postgres = ["asyncpg>=0.29.0", "psycopg[binary,pool]>=3.2.3"] test = [ @@ -323,6 +323,7 @@ exclude = [ ".ruff_cache", ".svn", ".venv", + "__pycache__", "__pypackages__", "_build", "buck-out", @@ -333,7 +334,7 @@ exclude = [ "tests/codegen/snapshots", "alembic/* ", ] -src = ["src/strawchemy", "tests"] +src = ["src", "tests"] [tool.ruff.lint] select = ["ALL"] diff --git a/tasks.md b/tasks.md index a0f38fe8..60aa896a 100644 --- a/tasks.md +++ b/tasks.md @@ -129,6 +129,12 @@ Format code Format code +## `ruff:pre-commit` + +- **Usage**: `ruff:pre-commit` + +Fix ruff errors and format (for pre-commit) + ## `slotscheck` - **Usage**: `slotscheck` diff --git a/uv.lock b/uv.lock index de61a6ee..b1e44d41 100644 --- a/uv.lock +++ b/uv.lock @@ -3369,7 +3369,7 @@ dev = [ { name = "pytest-lazy-fixtures" }, { name = "pytest-pretty" }, { name = "pytest-xdist" }, - { name = "ruff" }, + { name = "ruff", specifier = ">=0.14.10,<0.15" }, { name = "slotscheck", specifier = ">=0.16.5" }, { name = "sqlparse" }, { name = "syrupy" }, @@ -3380,7 +3380,7 @@ dev = [ doc = [{ name = "git-cliff", specifier = ">=2.6.1" }] lint = [ { name = "basedpyright" }, - { name = "ruff" }, + { name = "ruff", specifier = ">=0.14.10,<0.15" }, { name = "slotscheck", specifier = ">=0.16.5" }, { name = "vulture" }, ]