chore(tooling): wave 1 — mypy + eslint + prettier + CI + pre-commit#48
Merged
chore(tooling): wave 1 — mypy + eslint + prettier + CI + pre-commit#48
Conversation
Adds the safety net before refactor waves touch code: Python: - mypy baseline (permissive; strict on models.* + config; hotspots opted out per-module until Wave 3 refactors land) - expanded ruff rules: LOG, RET, PTH (BLE + TRY deferred to Wave 2 alongside the bare-except cleanup) - fixes 45 pre-existing ruff errors (module-top imports, SIM105/108, B904 raise-from, F841 dead vars) for a green baseline Frontend: - ESLint 9 flat config + @eslint/js + typescript-eslint strict preset - Prettier 3 config + ignore - @/ path aliases in tsconfig + vite - package.json scripts: lint, lint:fix, format, format:check, typecheck Quality gates: - pre-commit hooks: ruff, mypy, prettier, eslint - GitHub Actions CI: pytest + ruff + mypy + npm run lint + format:check + build + vitest on pushes and PRs to main - fixes a flaky env-leak in tests/test_config.py that left cfg in "managed" backend state across the suite, causing downstream tests to attempt real Anthropic API calls with an invalid key See docs/clean-code.md for the standard these tools enforce. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mechanical reformat of 56 files under frontend/ — double quotes, 100ch width, trailing commas, consistent arrow-param parens. Zero behavior changes. Establishes the format baseline that CI now enforces via \`npm run format:check\`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The taxonomy tests assumed the FastAPI lifespan had run and populated the DB with seed families (terraform-module-full et al.). Locally this "worked" because the dev DB persisted between uvicorn runs. In CI — fresh filesystem, no prior boot — the tables didn't exist and every query raised OperationalError: no such table: taxonomy_nodes. Root cause: TestClient(app) only intercepts HTTP; it does NOT trigger the lifespan unless used as a context manager. The rest of the suite gets away with this because those tests build their own state through endpoints; taxonomy tests specifically need the bootstrap. Fix: wrap the TestClient in "with ... as c:" inside the fixture so the lifespan runs, and point the bootstrap at a per-test temp DB so the dev DB stays clean and tests stay independent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wave 1 of the clean-code overhaul (see
docs/clean-code.md). Adds the safety net — every subsequent refactor wave runs behind green CI.No code-behavior changes. Mechanical lint fixes + config. This PR makes
maingreen on the new gates so Wave 2+ can land incremental refactors without flying blind.What's new
@/path aliases intsconfig.json+vite.config.ts..pre-commit-config.yamlrunning ruff + mypy + prettier + eslint..github/workflows/ci.ymlrunningpytest + ruff + mypy + npm run lint + format:check + build + vitest.Lint fixes bundled in
45 pre-existing ruff errors are addressed to establish a green baseline:
E402) — moved loggers below imports where practical,# noqawith reason where intentional (e.g.seeds/__init__.pyavoiding circular imports).B904raise-from inuploads.py,B008FastAPIFile()default noqa'd,B007unused loop var fixed.SIM105try/except/pass→contextlib.suppress,SIM108if/else → ternary.RET505unnecessary else after return,RET503missing explicit return at end of LLM retry loop.F841dead variable removed.Flaky test fix
tests/test_config.pypatchedSKILLFORGE_COMPETITOR_BACKEND=managedand reloadedskillforge.config. Thefinallyblock reloaded before monkeypatch teardown, leaving the module stuck inmanagedmode for downstream tests — which then tried to hit the real Anthropic API and failed with a 401. Fixed via a_restore_cfg()helper that explicitlydelenvs before the final reload.Before:
403 passed, 2 skipped, 1 failed(flaky).After:
403 passed, 2 skipped, 0 failed(stable).Commit layout
chore(tooling): wave 1 — ...— configs + substantive lint fixes.style: apply prettier to frontend— mechanical reformat of 56 files. Diff is pure whitespace — skim-only.Test plan
All verified locally. CI will run them again on push:
uv run ruff check skillforge— cleanuv run mypy skillforge— 51 files, 0 errors (17 excluded until later waves)uv run pytest tests/— 403 passed, 2 skippedcd frontend && npm run lint— cleancd frontend && npm run format:check— cleancd frontend && npm run build— passescd frontend && npm run test— 35/35 passWhat's next
Wave 2 lands the cross-cutting hygiene:
skillforge/errors.py, replace 75except Exceptionwith typed +logging.exception(...), killprint(...)diagnostics, extract_json.pyhelper, eliminate mutable module globals viarun_registry.py. All safe behind the test net this PR establishes.🤖 Generated with Claude Code