Skip to content

chore: replace flake8 and black with ruff - #1954

Merged
WilliamBergamin merged 4 commits into
mainfrom
chore/replace-flake8-black-with-ruff
Sep 2, 2026
Merged

chore: replace flake8 and black with ruff#1954
WilliamBergamin merged 4 commits into
mainfrom
chore/replace-flake8-black-with-ruff

Conversation

@WilliamBergamin

@WilliamBergamin WilliamBergamin commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces flake8 (lint) and black (format) with 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"]

Notes for reviewers:

  • 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

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 46.15385% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.06%. Comparing base (aa0cf44) to head (2bcdd49).
✅ 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 ⚠️

❌ Your patch check has failed because the patch coverage (46.15%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1954      +/-   ##
==========================================
- Coverage   84.06%   84.06%   -0.01%     
==========================================
  Files         118      118              
  Lines       13506    13505       -1     
==========================================
- Hits        11354    11353       -1     
  Misses       2152     2152              

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

@WilliamBergamin WilliamBergamin added semver:patch python Pull requests that update Python code dependencies Pull requests that update a dependency file labels Sep 2, 2026
@WilliamBergamin WilliamBergamin self-assigned this Sep 2, 2026
The ruff migration added `ignore = ["E402"]` to silence 13 violations in
the generated legacy_client.py, where codegen prepended `from asyncio
import Future` above the module docstring (demoting it to a plain
statement). Insert it after the docstring instead so all imports stay at
the top of the file, then drop the global ignore to keep E402 enforced
across slack/ and slack_sdk/.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@WilliamBergamin
WilliamBergamin marked this pull request as ready for review September 2, 2026 15:23
@WilliamBergamin
WilliamBergamin requested a review from a team as a code owner September 2, 2026 15:23
@WilliamBergamin
WilliamBergamin merged commit 1a38eb3 into main Sep 2, 2026
17 of 18 checks passed
@WilliamBergamin
WilliamBergamin deleted the chore/replace-flake8-black-with-ruff branch September 2, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file python Pull requests that update Python code semver:patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant