From f28175c9f9bd320ec3d2fbc7063ad70f684b1dba Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Wed, 30 Sep 2026 11:22:13 -0400 Subject: [PATCH 1/2] chore: replace flake8 and black with ruff Ports the bolt-python (#1566, #1567) and python-slack-sdk (#1954, #1959) migration in one change, since the only Python here is the tests/ folder. ruff check and ruff format replace flake8 and black; lint.sh now also gates on ruff format --check. Existing sources need no changes. Co-Authored-By: Claude --- .flake8 | 2 -- .github/maintainers_guide.md | 4 ++-- .github/workflows/ci-build.yml | 2 +- AGENTS.md | 6 +++--- pyproject.toml | 26 +++++++++++++++++++++++--- scripts/format.sh | 5 +++-- scripts/install_all_and_run_tests.sh | 4 ++-- scripts/lint.sh | 5 +++-- scripts/test.sh | 4 ++-- 9 files changed, 39 insertions(+), 19 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 51b50a0..0000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 100 \ No newline at end of file diff --git a/.github/maintainers_guide.md b/.github/maintainers_guide.md index d222f4a..67d1d44 100644 --- a/.github/maintainers_guide.md +++ b/.github/maintainers_guide.md @@ -47,10 +47,10 @@ This project contains an [`.editorconfig`](../.editorconfig) file. It is used by ### Linting & Formatting ```zsh -# Run flake8 & prettier from root directory for linting +# Run ruff & prettier from root directory for linting ./scripts/lint.sh -# Run black & prettier from root directory for code formatting +# Run ruff & prettier from root directory for code formatting ./scripts/format.sh ``` diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 9b2b016..114e8e4 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | pip install -U . - - name: Lint with flake8 & Prettier + - name: Lint with ruff & Prettier run: | bash scripts/lint.sh diff --git a/AGENTS.md b/AGENTS.md index 9c119ac..9f62d65 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,10 +20,10 @@ pip install -U -e . # Run a single test file ./scripts/test.sh tests/test_manifest_v2_schema.py -# Lint (flake8 for Python, Prettier for JSON) +# Lint (ruff for Python, Prettier for JSON) ./scripts/lint.sh -# Format (black for Python, Prettier for JSON) +# Format (ruff for Python, Prettier for JSON) ./scripts/format.sh ``` @@ -37,7 +37,7 @@ Tests validate manifests against the schema using `jsonschema.validate()`. Each ## Style -- Python: black, line length 100, flake8 +- Python: ruff (lint + format), line length 100, config in `pyproject.toml` - JSON: Prettier, 2-space indent, LF line endings (see `.editorconfig`) - Tests use pytest with `GIVEN/WHEN/THEN` comment structure diff --git a/pyproject.toml b/pyproject.toml index 865e499..6d2f489 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,8 +6,7 @@ license = "MIT" license-files = ["LICENSE"] authors = [{ name = "Slack Technologies, LLC", email = "opensource@slack.com" }] dependencies = [ - "flake8==7.4.1", - "black==26.5.1", + "ruff==0.16.4", "pytest==9.1.1", "jsonschema==4.26.0", ] @@ -15,9 +14,30 @@ dependencies = [ [tool.setuptools] packages = ["tests"] -[tool.black] +[tool.ruff] line-length = 100 +[tool.ruff.lint] +select = ["E", "W", "F", "D"] +ignore = [ + # missing-docstring: do not add docstrings where none exist + "D100", + "D101", + "D102", + "D103", + "D104", + "D105", + "D106", + "D107", +] + +[tool.ruff.lint.pydocstyle] +# Keep `select = ["D"]` a bare category select; listing explicit D codes would override this convention. +convention = "google" + +[tool.ruff.format] +docstring-code-format = true + [tool.pytest.ini_options] testpaths = ["tests"] log_file = "logs/pytest.log" diff --git a/scripts/format.sh b/scripts/format.sh index d86a57b..6ea7f51 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,7 +1,8 @@ #!/bin/bash -# ./scripts/run_flake8.sh +# ./scripts/format.sh script_dir=$(dirname $0) cd ${script_dir}/.. && \ - black tests/ && \ + ruff check --fix tests/ && \ + ruff format tests/ && \ npx prettier --write schemas/**/*.json *.json tests/**/*.json diff --git a/scripts/install_all_and_run_tests.sh b/scripts/install_all_and_run_tests.sh index 1929862..09f0002 100755 --- a/scripts/install_all_and_run_tests.sh +++ b/scripts/install_all_and_run_tests.sh @@ -12,11 +12,11 @@ pip install -U -e . if [[ $test_target != "" ]] then - black tests/ && \ + ruff format tests/ && \ npx prettier --write schemas/**/*.json *.json tests/**/*.json && \ pytest $1 else - black tests/ && \ + ruff format tests/ && \ npx prettier --write schemas/**/*.json *.json tests/**/*.json && \ pytest fi diff --git a/scripts/lint.sh b/scripts/lint.sh index d8596d6..23f7d56 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -1,7 +1,8 @@ #!/bin/bash -# ./scripts/run_flake8.sh +# ./scripts/lint.sh script_dir=$(dirname $0) cd ${script_dir}/.. && \ - flake8 tests/ && \ + ruff check tests/ && \ + ruff format --check tests/ && \ npx prettier --check schemas/**/*.json *.json tests/**/*.json diff --git a/scripts/test.sh b/scripts/test.sh index effee5f..b365280 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -10,8 +10,8 @@ test_target="$1" if [[ $test_target != "" ]] then - black tests/ && \ + ruff format tests/ && \ pytest -vv $1 else - black tests/ && pytest -vv + ruff format tests/ && pytest -vv fi From 62487e8b2a04aec07d4a9500cf5a375ff7cd1154 Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Wed, 30 Sep 2026 12:46:45 -0400 Subject: [PATCH 2/2] chore: call format.sh from the test scripts test.sh and install_all_and_run_tests.sh now delegate formatting to scripts/format.sh instead of inlining ruff/prettier, so the formatting steps live in one place. Also drops an unneeded pyproject.toml comment. Co-Authored-By: Claude --- pyproject.toml | 1 - scripts/install_all_and_run_tests.sh | 6 ++---- scripts/test.sh | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6d2f489..1307b7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,6 @@ ignore = [ ] [tool.ruff.lint.pydocstyle] -# Keep `select = ["D"]` a bare category select; listing explicit D codes would override this convention. convention = "google" [tool.ruff.format] diff --git a/scripts/install_all_and_run_tests.sh b/scripts/install_all_and_run_tests.sh index 09f0002..9d43ff3 100755 --- a/scripts/install_all_and_run_tests.sh +++ b/scripts/install_all_and_run_tests.sh @@ -12,11 +12,9 @@ pip install -U -e . if [[ $test_target != "" ]] then - ruff format tests/ && \ - npx prettier --write schemas/**/*.json *.json tests/**/*.json && \ + ./scripts/format.sh && \ pytest $1 else - ruff format tests/ && \ - npx prettier --write schemas/**/*.json *.json tests/**/*.json && \ + ./scripts/format.sh && \ pytest fi diff --git a/scripts/test.sh b/scripts/test.sh index b365280..0734b77 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -10,8 +10,8 @@ test_target="$1" if [[ $test_target != "" ]] then - ruff format tests/ && \ + ./scripts/format.sh && \ pytest -vv $1 else - ruff format tests/ && pytest -vv + ./scripts/format.sh && pytest -vv fi