Skip to content

Feat: Replace flake8, black and husky with ruff + pre-commit#1846

Open
MarceloRobert wants to merge 4 commits intokernelci:mainfrom
MarceloRobert:feat/ruff
Open

Feat: Replace flake8, black and husky with ruff + pre-commit#1846
MarceloRobert wants to merge 4 commits intokernelci:mainfrom
MarceloRobert:feat/ruff

Conversation

@MarceloRobert
Copy link
Copy Markdown
Collaborator

@MarceloRobert MarceloRobert commented Apr 9, 2026

Important

This PR will be broken in 2, first we will reformat the files bypassing all checks and then we will push the configs and a .git-blame-ignore-revs so that we can use as many rules as possible, all while keeping the blame ability

Changes

  • Replaced Flake8 + Black with Ruff
  • Updated CI to use Ruff
  • Auto-fixed backend linting and formatting issues
  • Replaced Husky with Pre-commit
  • Updated documentation

Note

I decided to ignore the /commands folder from linting as there were a lot of functions that went over the complexity limit of 10 (which was previously 11) not only because there would be a lot of refactoring but also because it is pretty easy for the commands to get complex.

How to test

  • Update frontend dependencies with pnpm install (this will uninstall Husky)
  • Update backend dependencies with poetry install (this will install Ruff and Pre-commit and uninstall Black and Flake8)
  • Check backend formatting with poetry run ruff format --check
  • Check backend linting with poetry run ruff check
  • Verify Git is no longer using a custom hooks path (Husky removed) with git config --get core.hooksPath
    • Expected: no output (or empty value).
  • Install repository hooks from pre-commit config: poetry -C backend run pre-commit install --hook-type pre-commit --hook-type pre-push --install-hooks
    • Expected: installation messages for both pre-commit and pre-push.
  • Validate pre-commit config: poetry -C backend run pre-commit validate-config
  • Run all pre-commit stage checks manually: poetry -C backend run pre-commit run --hook-stage pre-commit --all-files
    • Expected: Ruff checks + frontend lint/typecheck hooks pass.
  • Run all pre-push stage checks manually: poetry -C backend run pre-commit run --hook-stage pre-push --all-files
    • Expected: pre-push stage passes (including the frontend pre-push guard hook).
  • Smoke-test with real hook execution:
    • Make a small local change and run git commit to confirm pre-commit hooks execute.
    • Run git push --dry-run (or push to a test branch) to confirm pre-push hooks execute.

Reference / Useful Links

Closes #1845

@MarceloRobert MarceloRobert self-assigned this Apr 9, 2026
@MarceloRobert MarceloRobert added the CI/CD Most or all of the changes are about automated tests / Github's CI label Apr 9, 2026
Copy link
Copy Markdown
Contributor

@dede999 dede999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like pretty much the idea of so many unrelated changes, but as they were made by the new linter rules, there is no real point in complaining about them. I only many a small suggestion but it must not lock the merge of the PR it it takes too long

name: frontend pre-push
entry: bash
args:
- -lc
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is it possible to extract this script (lines 31-47) to a shell script? Would it take too much time?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could but then we would be going back to having separate files for the pre-push of the frontend, I don't think this is needed for now

Not formatting yet, just configs
Replaces husky as a hook manager with pre-commit manager as per new contributing guidelines. This also improves the readability of the hooks as everything is in a single file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD Most or all of the changes are about automated tests / Github's CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace flake8 and black with Ruff

2 participants