From 57c1cdbf98b6a4114b75e1bacb9b7b850f61d787 Mon Sep 17 00:00:00 2001 From: bartzbeielstein <32470350+bartzbeielstein@users.noreply.github.com> Date: Mon, 8 Jun 2026 00:49:58 +0200 Subject: [PATCH] chore(tooling): converge on ty, add coverage ratchet + docs-reference CI gate Roadmap #5/#6 tooling baseline for spotforecast2-safe: - type checker: drop mypy (dev + optional-deps + pre-commit hook), adopt Astral `ty`; add [tool.ty]; run `ty check src/` non-blocking in CI. - coverage: add [tool.coverage] with fail_under=68 ratchet (~71% today), enforced by the existing pytest --cov run. - legacy lint: remove redundant .flake8 (not invoked anywhere; flake8 also dropped from runtime deps) and add a minimal [tool.ruff] (line-length 88). - docs (#5): new "API Reference In Sync" CI job regenerates the quartodoc reference and fails on drift (git diff --exit-code docs/reference/). Non-breaking, non-releasing (chore). Promotes to main with the next release. Co-Authored-By: Claude Opus 4.8 (1M context) --- .flake8 | 3 --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 12 +++--------- REUSE.toml | 2 +- pyproject.toml | 29 +++++++++++++++++++++++++---- 5 files changed, 63 insertions(+), 17 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 6d0f5c9a1..000000000 --- a/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length = 180 -extend-ignore = E203 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f4354f62..a1c1313f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -187,6 +187,11 @@ jobs: ruff check src/ tests/ continue-on-error: true + - name: Type check with ty (non-blocking) + run: | + ty check src/ + continue-on-error: true + security: name: Security Scan runs-on: ubuntu-latest @@ -229,3 +234,32 @@ jobs: sarif_file: bandit-report.sarif category: bandit continue-on-error: true + + docs-reference-sync: + name: API Reference In Sync + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + + - name: Set up uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + cache-dependency-glob: "pyproject.toml" + + - name: Regenerate the quartodoc API reference + run: | + uv run python docs/quartodoc_build.py + uv run quartodoc interlinks + + - name: Fail if committed docs/reference is stale + run: | + if ! git diff --exit-code -- docs/reference/; then + echo "::error::docs/reference is out of sync with quartodoc. Run 'uv run python docs/quartodoc_build.py && uv run quartodoc interlinks' locally and commit the result." + exit 1 + fi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 455459079..a3ce1b7e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,15 +38,9 @@ repos: - id: ruff args: [--fix] - # Type checking - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 - hooks: - - id: mypy - additional_dependencies: - - types-all - args: [--no-error-summary] - exclude: ^(tests/|docs/) + # Type checking now runs in CI via Astral `ty` (non-blocking); the heavy + # mypy + types-all pre-commit hook was removed during the tooling-baseline + # convergence (roadmap #6). # YAML validation - repo: https://github.com/pre-commit/pre-commit-hooks diff --git a/REUSE.toml b/REUSE.toml index c4b5bfcdc..92fe34251 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -4,7 +4,7 @@ SPDX-PackageSupplier = "bartzbeielstein <32470350+bartzbeielstein@users.noreply. SPDX-PackageDownloadLocation = "https://github.com/sequential-parameter-optimization/spotforecast2-safe" [[annotations]] -path = [".flake8", ".gitignore", ".python-version", ".releaserc.json", ".semantic-release-init", "mkdocs.yml", "pyproject.toml", "uv.lock", "junit.xml"] +path = [".gitignore", ".python-version", ".releaserc.json", ".semantic-release-init", "mkdocs.yml", "pyproject.toml", "uv.lock", "junit.xml"] precedence = "aggregate" SPDX-FileCopyrightText = "2026 bartzbeielstein" SPDX-License-Identifier = "AGPL-3.0-or-later" diff --git a/pyproject.toml b/pyproject.toml index bf6a47d90..56c395b93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,6 @@ requires-python = ">=3.13" dependencies = [ "astral>=3.2,<4.0", "feature-engine>=1.9.3,<2.0", - "flake8>=7.3.0,<8.0", "holidays>=0.90,<1.0", "lightgbm>=4.6.0,<5.0", "numba>=0.63.1,<1.0", @@ -58,8 +57,8 @@ dev = [ # ── Security scanning ──────────────────────────────────────────────────── "safety>=3.0.0,<4.0", "bandit>=1.8.0,<2.0", - # ── Type checking ──────────────────────────────────────────────────────── - "mypy>=1.8.0,<3.0", + # ── Type checking (Astral ty; non-blocking in CI) ──────────────────────── + "ty>=0.0.29", ] [project.optional-dependencies] @@ -76,7 +75,7 @@ dev = [ "nbformat>=5.10.4", "safety>=3.0.0,<4.0", "bandit>=1.8.0,<2.0", - "mypy>=1.8.0,<3.0", + "ty>=0.0.29", ] [project.scripts] @@ -116,3 +115,25 @@ target-version = ["py313"] # explicit profile keeps the two formatters in agreement regardless of version. [tool.isort] profile = "black" + +# Ruff config (replaces the removed legacy .flake8). Line length matches black; +# the default rule set (pyflakes + pycodestyle E/F) is kept. CI runs +# `ruff check` non-blocking (see .github/workflows/ci.yml). +[tool.ruff] +line-length = 88 +target-version = "py313" + +[tool.coverage.run] +branch = true +source = ["src/spotforecast2_safe"] + +[tool.coverage.report] +# Ratchet: lock in the current ~71% coverage (measured locally) so it cannot +# regress; 68 leaves a small margin for platform variance on CI. Raise +# deliberately as coverage improves. CI runs pytest with --cov, enforcing this. +fail_under = 68 + +# Astral `ty` type checker. Run non-blocking in CI (continue-on-error) so it +# surfaces type debt without failing the build; tighten to a gate later. +[tool.ty.environment] +python-version = "3.13"