Skip to content

Commit 1a38eb3

Browse files
WilliamBergaminClaude
andauthored
chore: replace flake8 and black with ruff (#1954)
Co-authored-by: Claude <svc-devxp-claude@slack-corp.com>
1 parent aa0cf44 commit 1a38eb3

43 files changed

Lines changed: 104 additions & 126 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.flake8‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎.vscode/settings.json‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"python.linting.pylintEnabled": false,
4-
"python.linting.flake8Enabled": true,
53
"python.venvPath": "${workspaceFolder}/env",
6-
"python.formatting.provider": "black",
74
"editor.formatOnSave": true,
8-
"python.linting.enabled": true,
9-
}
5+
"[python]": {
6+
"editor.defaultFormatter": "charliermarsh.ruff",
7+
"editor.codeActionsOnSave": {
8+
"source.fixAll.ruff": "explicit"
9+
}
10+
}
11+
}

‎AGENTS.md‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Each contains a header warning:
6464
# DO NOT EDIT THIS FILE
6565
# 1) Modify slack_sdk/web/client.py
6666
# 2) Run `python scripts/codegen.py`
67-
# 3) Run `black slack_sdk/`
67+
# 3) Run `ruff format slack_sdk/`
6868
```
6969

7070
**How it works:**
@@ -215,8 +215,8 @@ Available scripts in the `scripts/` directory:
215215

216216
All tooling configuration is defined in the following files:
217217

218-
- **Formatter**: `black` — see `[tool.black]` in `pyproject.toml`
219-
- **Linter**: `flake8` — see `.flake8`
218+
- **Formatter**: `ruff format` — see `[tool.ruff]` in `pyproject.toml`
219+
- **Linter**: `ruff check` — see `[tool.ruff.lint]` in `pyproject.toml`
220220
- **Type checker**: `mypy` — see `[tool.mypy]` in `pyproject.toml`
221221
- **Test runner**: `pytest` — see `[tool.pytest.ini_options]` in `pyproject.toml`
222222
- **Coverage**: `pytest-cov` reporting to Codecov
@@ -226,7 +226,7 @@ All tooling configuration is defined in the following files:
226226

227227
- Testing: `requirements/testing.txt`
228228
- Optional runtime: `requirements/optional.txt`
229-
- Dev tools (black, flake8, mypy): `requirements/tools.txt`
229+
- Dev tools (ruff, mypy): `requirements/tools.txt`
230230

231231
## CI Pipeline (GitHub Actions)
232232

@@ -244,8 +244,7 @@ Defined in `.github/workflows/ci-build.yml`, runs on push to `main`, all PRs, an
244244

245245
**Configuration:**
246246

247-
- `pyproject.toml` — Project metadata, build config, tool settings (black, pytest, mypy)
248-
- `.flake8` — Flake8 linter configuration
247+
- `pyproject.toml` — Project metadata, build config, tool settings (ruff, pytest, mypy)
249248
- `requirements/*.txt` — Dependency specifications
250249

251250
**Tooling:**

‎integration_tests/rtm/test_issue_530.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_issue_530(self):
2727
self.fail("Raising an error here was expected")
2828
except Exception as e:
2929
self.assertEqual(
30-
"The request to the Slack API failed.\n" "The server responded with: {'ok': False, 'error': 'invalid_auth'}",
30+
"The request to the Slack API failed.\nThe server responded with: {'ok': False, 'error': 'invalid_auth'}",
3131
str(e),
3232
)
3333
finally:
@@ -42,7 +42,7 @@ async def test_issue_530_async(self):
4242
self.fail("Raising an error here was expected")
4343
except Exception as e:
4444
self.assertEqual(
45-
"The request to the Slack API failed.\n" "The server responded with: {'ok': False, 'error': 'invalid_auth'}",
45+
"The request to the Slack API failed.\nThe server responded with: {'ok': False, 'error': 'invalid_auth'}",
4646
str(e),
4747
)
4848
finally:

‎integration_tests/samples/conversations/open_dm.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
client = WebClient(token=os.environ["SLACK_API_TOKEN"])
1212

1313
all_users = client.users_list(limit=100)["members"]
14-
joinable_only = (
15-
lambda u: u["id"] != "USLACKBOT"
14+
joinable_only = lambda u: (
15+
u["id"] != "USLACKBOT"
1616
and not u["is_bot"]
1717
and not u["is_app_user"]
1818
and not u["deleted"]

‎integration_tests/web/test_admin_conversations_restrictAccess.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def setUp(self):
4343
self.channel_id = client.conversations_create(
4444
name=channel_name,
4545
is_private=True,
46-
)[
47-
"channel"
48-
]["id"]
46+
)["channel"]["id"]
4947

5048
def tearDown(self):
5149
pass

‎integration_tests/web/test_calls.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ def test_sync(self):
2929
lambda u: not u["deleted"] and "bot_id" not in u,
3030
client.users_list(limit=50)["members"],
3131
)
32-
)[
33-
0
34-
]["id"]
32+
)[0]["id"]
3533

3634
new_call = client.calls_add(
3735
external_unique_id=str(uuid.uuid4()),

‎pyproject.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ optional-dependencies.optional = { file = ["requirements/optional.txt"] }
5555
[tool.distutils.bdist_wheel]
5656
universal = true
5757

58-
[tool.black]
58+
[tool.ruff]
5959
line-length = 125
6060

61+
[tool.ruff.lint]
62+
select = ["E", "W", "F"]
63+
6164
[tool.pytest.ini_options]
6265
testpaths = ["tests"]
6366
log_file = "logs/pytest.log"

‎requirements/tools.txt‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@
33
# mypy
44
mypy<=2.3.1
55

6-
# flake8
7-
flake8>=7.3.0,<8
8-
9-
# black
10-
black==26.3.1
6+
# ruff
7+
ruff==0.16.4

‎scripts/codegen.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"#\n"
1616
"# 1) Modify slack_sdk/web/client.py\n"
1717
"# 2) Run `python scripts/codegen.py`\n"
18-
"# 3) Run `black slack_sdk/`\n"
18+
"# 3) Run `ruff format slack_sdk/`\n"
1919
"#\n"
2020
"# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
2121
"\n"
@@ -101,7 +101,9 @@
101101
with open(f"{args.path}/slack_sdk/web/async_client.py", "w") as output:
102102
output.write(async_source)
103103

104-
legacy_source = header + "from asyncio import Future\n" + source
104+
docstring = '"""A Python module for interacting with Slack\'s Web API."""\n'
105+
legacy_source = header + source
106+
legacy_source = legacy_source.replace(docstring, docstring + "\nfrom asyncio import Future\n", 1)
105107
legacy_source = re.sub("-> SlackResponse", "-> Union[Future, SlackResponse]", legacy_source)
106108
legacy_source = re.sub(
107109
"from .base_client import BaseClient, SlackResponse",

0 commit comments

Comments
 (0)