Skip to content

chore: replace flake8 and black with ruff - #1954

Draft
WilliamBergamin wants to merge 2 commits into
mainfrom
chore/replace-flake8-black-with-ruff
Draft

chore: replace flake8 and black with ruff#1954
WilliamBergamin wants to merge 2 commits into
mainfrom
chore/replace-flake8-black-with-ruff

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

Summary

Replaces the two separate dev tools — flake8 (lint) and black (format) — with a single ruff binary that does both. This mirrors slackapi/bolt-python#1566.

Chosen for the simplest config that changes the source the least: a narrow lint select = ["E", "W", "F"] (mirroring flake8's pycodestyle + pyflakes) with ignore = ["E402"], and ruff format (a near-drop-in for black).

Two commits:

  • chore: replace flake8 and black with ruff — the tooling swap: [tool.ruff] + [tool.ruff.lint] in pyproject.toml, delete .flake8, ruff==0.16.4 in requirements/tools.txt, rewrite scripts/format.sh / scripts/lint.sh, update the "Running black" echoes in the runner scripts, point scripts/codegen.py's generated-file header at ruff format, update .vscode/settings.json and AGENTS.md.
  • style: apply ruff format across the codebase — a one-time mechanical reformat. Only the documented ruff-vs-black differences (implicit string-concat joining, f-string inner-quote normalization, blank-line-at-block-start removal, subscript/lambda reflow) plus ruff's formatting of Python code blocks inside Markdown. No behavior changes.

Notes for reviewers:

  • The ignore list is ["E402"] only — this repo's .flake8 carried no ignores, and E402 is the only code that fires (all in the generated slack_sdk/web/legacy_client.py header region). Existing inline # noqa: F821 comments keep handling those spots precisely.
  • No # fmt: skip guards were needed: mypy (warn_unused_ignores) passes clean because the reflow-sensitive # type: ignore lines keep their magic trailing commas.
  • ⚠️ Follow-up: since this will be squash-merged, the reformat commit's SHA doesn't survive. A separate follow-up PR should add the squashed commit's SHA to .git-blame-ignore-revs so git blame skips the reformat.

Testing

  • ./scripts/lint.sh --no-install455 files already formatted / All checks passed!
  • ./scripts/run_mypy.sh --no-installSuccess
  • python scripts/codegen.py --path . + ./scripts/format.sh --no-install → generated files stable and reference ruff format
  • Targeted unit tests for the reformatted modules (models, web, oauth) pass (635 passed). Full run_validation.sh not yet run end-to-end locally — left for final verification.

Category

  • tests/integration_tests (Automated tests for this library)
  • /docs (Documents)
  • Others (repo-wide dev tooling; cosmetic-only formatting reaches every package)

Requirements

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

🤖 Generated with Claude Code

WilliamBergamin and others added 2 commits September 1, 2026 13:56
Swap the two separate dev tools -- flake8 (lint) and black (format) -- for
a single ruff binary that does both.

- pyproject.toml: add [tool.ruff] (line-length = 125) and [tool.ruff.lint]
  with select = ["E", "W", "F"]; ignore = ["E402"] (the only code that
  fires, all in the generated legacy_client.py header region). Drop
  [tool.black].
- requirements/tools.txt: replace flake8 and black with ruff==0.16.4.
- delete .flake8 (its only setting, max-line-length, now lives in
  [tool.ruff]).
- scripts/format.sh: ruff check --fix + ruff format.
- scripts/lint.sh: ruff format --check + ruff check.
- scripts/{run_tests,run_validation,run_integration_tests}.sh: update the
  "Running black" echo to reference ruff.
- scripts/codegen.py: emit `ruff format slack_sdk/` in the generated-file
  header; regenerate async_client.py, legacy_client.py, async_chat_stream.py.
- .vscode/settings.json: use the ruff extension for formatting/linting.
- AGENTS.md: update formatter/linter/tooling references to ruff.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
One-time mechanical reformat from adopting `ruff format` in place of black.
Only the documented ruff-vs-black differences (implicit string-concat
joining, f-string inner-quote normalization, blank-line-at-block-start
removal, subscript/lambda reflow) plus ruff's formatting of Python code
blocks inside Markdown. No behavior changes.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.00000% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.03%. Comparing base (49101ef) to head (23b4ae4).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
slack_sdk/socket_mode/builtin/connection.py 28.57% 5 Missing ⚠️
slack_sdk/rtm_v2/__init__.py 0.00% 4 Missing ⚠️
slack_sdk/socket_mode/builtin/client.py 50.00% 2 Missing ⚠️
slack_sdk/models/messages/message.py 0.00% 1 Missing ⚠️
slack_sdk/web/async_internal_utils.py 50.00% 1 Missing ⚠️
slack_sdk/web/internal_utils.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1954      +/-   ##
==========================================
- Coverage   84.06%   84.03%   -0.03%     
==========================================
  Files         118      118              
  Lines       13506    13506              
==========================================
- Hits        11354    11350       -4     
- Misses       2152     2156       +4     

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

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