Skip to content

chore(ci): replace black and flake8/Hound CI with ruff - #813

Open
ceache wants to merge 2 commits into
python-zk:masterfrom
ceache:feature/ruff-migration
Open

ceache wants to merge 2 commits into
python-zk:masterfrom
ceache:feature/ruff-migration

Conversation

@ceache

@ceache ceache commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Addresses #774

Summary

This PR modernizes Kazoo's linting, formatting, and PR review workflow:

  1. Ruff Migration: Replaces Black and Flake8 with Ruff (pinned to 0.16.7), unifying linting and formatting under a single tool.
  2. HoundCI Retirement & Reviewdog Replacement: Retires HoundCI in favor of Reviewdog, delivering fast and reliable inline comments on PR diffs directly within GitHub Actions.
  3. CI & Tox Optimization: Replaces the multiple separate black and pep8 tox virtualenvs in CI with a single unified ruff environment, significantly speeding up validation runs.

Important: Branch Protection Update Required

In python-zk/kazoo repository settings, the master branch protection rule currently has Hound listed under required_status_checks:

  • Repository maintainers/admins will need to remove Hound from the required status checks in branch protection settings (and optionally require Code Validation instead).
  • Otherwise, future PRs will be blocked waiting for a Hound status check that no longer runs.

Key Changes

  • HoundCI Retirement & Reviewdog Integration:
    • Removed .hound.yml and .flake8.
    • Added Reviewdog step via reviewdog/action-setup@v1 to .github/workflows/testing.yml using Ruff's native --output-format=rdjson with -reporter=github-pr-review and -filter-mode=added. This replicates HoundCI's inline commenting on PR diffs without external third-party bot flakiness.
  • Ruff Migration & Configuration:
    • Replaced [tool.black] with [tool.ruff], [tool.ruff.lint], and [tool.ruff.format] in pyproject.toml.
    • Configured Ruff lint rules (select = ["E", "F", "W"], builtins = ["_"], matching ignores E203, E721, F401, F811, F821) and line-length = 79 to maintain consistency with existing Flake8 and Black rules.
    • Set target-version = "py39".
    • Pinned Ruff to ruff==0.16.7 in [dependency-groups] and dropped unused black and pep8 groups.
  • Tox & CI Environments:
    • Added unified [testenv:ruff] in tox.ini running both ruff check and ruff format --check.
    • Preserved [testenv:pep8] and [testenv:black] for local developer workflows with deprecation notices pointing developers to the ruff environment.
    • Updated CI in .github/workflows/testing.yml to run TOX_VENV: ruff,mypy (one lint/format virtualenv instead of two).
  • Formatting Consistency & Git Blame Preservation:
    • Formatted 12 files where Ruff's AST formatter slightly differed from Black (multiline implicit string joining and trailing comments on call arguments).
    • Added the reformat commit hash to .git-blame-ignore-revs under # Reformat using ruff 0.16.7 to preserve git blame history.

Verification

  • tox -e ruff,mypy: All checks pass cleanly (62 files formatted, 0 lint violations, 0 typing issues).
  • tox -e pep8 and tox -e black: Display deprecation notices and pass.

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.96%. Comparing base (79cae1f) to head (8759aee).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
kazoo/client.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #813   +/-   ##
=======================================
  Coverage   94.96%   94.96%           
=======================================
  Files          27       27           
  Lines        3811     3811           
=======================================
  Hits         3619     3619           
  Misses        192      192           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pyproject.toml
@ThosRTanner

Copy link
Copy Markdown
Contributor

FIxes #774 I think

@ceache
ceache force-pushed the feature/ruff-migration branch 2 times, most recently from cbb7f79 to eaf133f Compare September 18, 2026 01:29
Comment thread tox.ini Outdated
Comment thread .hound.yml Outdated
Comment thread .github/workflows/testing.yml Outdated
Comment thread .github/workflows/testing.yml Outdated
@ceache
ceache force-pushed the feature/ruff-migration branch from eaf133f to 64cf8a7 Compare September 18, 2026 02:05
@ceache
ceache force-pushed the feature/ruff-migration branch from 64cf8a7 to 4f2d638 Compare September 19, 2026 01:23
@ceache ceache changed the title chore(ci): replace black and flake8 with ruff and reviewdog chore(ci): replace black and flake8/Hound CI with ruff Sep 19, 2026
@ceache
ceache force-pushed the feature/ruff-migration branch from 4f2d638 to 8917f5d Compare September 19, 2026 01:30
@ceache
ceache force-pushed the feature/ruff-migration branch from 8917f5d to 8759aee Compare September 19, 2026 01:35
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.

3 participants