Skip to content

refactor: replace Black with Ruff, add pre-commit hooks#143

Merged
Hugo0 merged 3 commits intomainfrom
worktree-tooling-improvements
Mar 14, 2026
Merged

refactor: replace Black with Ruff, add pre-commit hooks#143
Hugo0 merged 3 commits intomainfrom
worktree-tooling-improvements

Conversation

@Hugo0
Copy link
Owner

@Hugo0 Hugo0 commented Mar 14, 2026

Summary

  • Replace Black with Ruff — same formatting output, adds linting (pyflakes, pycodestyle, isort, bugbear, simplify, pyupgrade)
  • Add pre-commit hooks (.pre-commit-config.yaml) with Ruff + Prettier — catches issues before push
  • Remove unused Flask-FlatPages dependency
  • Auto-fixed 111 lint issues, 4 manual fixes in test_definitions.py
  • webapp/ and tests/ are fully lint-clean; scripts/ has 64 remaining warnings (style, non-blocking)
  • Net -164 lines

What's NOT included (intentional)

  • No ESLintvue-tsc --noEmit with strict mode already catches unused locals/params in CI
  • No Bun — compat risk with vue-tsc, Playwright, Render; pnpm works fine

Test plan

  • uv run ruff check webapp/ tests/ — all clean
  • uv run ruff format --check webapp/ tests/ — all clean
  • pnpm format:check — all clean
  • pnpm test — 81 passed
  • uv run pytest tests/ — 2029 passed, 289 skipped, 4 xfailed
  • pnpm build — builds successfully
  • CI passes

Setup after merge

Run pre-commit install once to activate hooks locally.

@coderabbitai review

Summary by CodeRabbit

  • Bug Fixes

    • Improved daily-word validation to reject Roman numerals.
  • Chores

    • Switched project formatting/linting tooling to Ruff.
    • Added runtime loading of local environment variables.
    • Removed obsolete public API functions.
  • Documentation

    • Updated pre-commit and contributor guidance to reflect new lint/format workflow.

@coderabbitai
Copy link

coderabbitai bot commented Mar 14, 2026

Warning

Rate limit exceeded

@Hugo0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 30 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e97a370a-6bca-45f6-abdc-910eb24eb450

📥 Commits

Reviewing files that changed from the base of the PR and between c9fc16d and 36581a2.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (26)
  • .github/workflows/test.yml
  • .pre-commit-config.yaml
  • CLAUDE.md
  • pyproject.toml
  • scripts/analyze_word_quality.py
  • scripts/configs.ipynb
  • scripts/curate_words.py
  • scripts/deprecated/capture_wiktionary_fixtures.py
  • scripts/hunspellToJSON.py
  • scripts/improve_word_lists.py
  • scripts/languages.ipynb
  • scripts/languages_characters.ipynb
  • scripts/playground.ipynb
  • scripts/solver.ipynb
  • scripts/status.ipynb
  • scripts/utils/google_trans_new.py
  • tests/conftest.py
  • tests/deprecated/test_wiktionary.py
  • tests/deprecated/test_wiktionary_definitions.py
  • tests/deprecated/test_wiktionary_parser.py
  • tests/test_daily_word.py
  • tests/test_definitions.py
  • tests/test_language_config.py
  • tests/test_word_lists.py
  • webapp/app.py
  • webapp/definitions.py
📝 Walkthrough

Walkthrough

Migrates Python formatting/linting from Black to Ruff, adds pre-commit hooks (Ruff, Prettier), removes several unused imports, normalizes file open calls to implicit read mode, adjusts minor error-handling and string-formatting styles, and removes two deprecated public lookup functions referenced by tests.

Changes

Cohort / File(s) Summary
Linting & CI
.github/workflows/test.yml, .pre-commit-config.yaml, pyproject.toml, CLAUDE.md
Replaces Black with Ruff in CI and project config; adds Ruff hooks and Prettier pre-commit; updates pyproject to [tool.ruff] settings, lint selectors, and target Python version.
Webapp I/O & Startup
webapp/app.py, webapp/definitions.py
Removes explicit "r" from many open() calls, switches some except IOError -> OSError, loads local .env at startup, and tidies imports and boolean checks; no route/signature changes.
Scripts — cleanup & formatting
scripts/...
scripts/analyze_word_quality.py, scripts/curate_words.py, scripts/hunspellToJSON.py, scripts/improve_word_lists.py, scripts/utils/google_trans_new.py, scripts/deprecated/..., scripts/*.ipynb
Removes unused imports (os, shutil, glob, random), modernizes string formatting to f-strings, normalizes spacing, simplifies some open() calls, minor exception and import reorderings; behavior unchanged.
Tests — imports & assertions
tests/conftest.py, tests/deprecated/*, tests/test_daily_word.py, tests/test_definitions.py, tests/test_language_config.py, tests/test_word_lists.py
Reorders/removes unused imports, omits explicit read mode in open(), consolidates patch contexts, refactors assertions, introduces is_roman_numeral check in word-list test, and removes references to lookup_kaikki_native and lookup_kaikki_english from test imports.
Notebooks & data-loading cells
scripts/*.ipynb, scripts/languages.ipynb, scripts/languages_characters.ipynb, scripts/playground.ipynb, scripts/solver.ipynb, scripts/status.ipynb
Condenses multi-line expressions to single lines, removes unused imports, and standardizes open() usage to implicit read mode; no logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 In codebunny hops, Ruff nibbles Black away,

Imports trimmed, and open()s now gently say,
"Read by default, no mode declared,"
Hooks pre-commit, our style repaired.
A small carrot of cleanup — hop, hooray! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main changes: replacing Black with Ruff for Python formatting/linting and adding pre-commit hooks configuration, which are the primary objectives throughout the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 81.54% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch worktree-tooling-improvements
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Hugo0 added 3 commits March 14, 2026 13:47
- Replace Black formatter with Ruff (format + lint) — same formatting
  output, adds linting (pyflakes, pycodestyle, isort, bugbear, simplify)
- Add .pre-commit-config.yaml with Ruff + Prettier hooks
- Auto-fix 111 lint issues (unused imports, f-strings, import sorting)
- Fix 4 SIM117 issues in test_definitions.py (nested with → combined)
- Remove unused Flask-FlatPages dependency
- Update CI workflow: ruff check + ruff format replaces black --check
- Update CLAUDE.md with new commands
- Exclude deprecated dirs from linting

Scripts still have 64 lint warnings (mostly style) — not blocking.
Scripts have 64 pre-existing lint warnings (notebooks, utilities) that
aren't worth fixing. Scope CI to production code only.
@Hugo0 Hugo0 force-pushed the worktree-tooling-improvements branch from b484bd5 to 36581a2 Compare March 14, 2026 13:48
@Hugo0 Hugo0 merged commit 0e3d046 into main Mar 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant