You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Never edit auto-generated files directly.** They contain a header:
56
+
**NEVER edit these auto-generated files:**
91
57
58
+
-`slack_sdk/web/async_client.py`
59
+
-`slack_sdk/web/legacy_client.py`
60
+
-`slack_sdk/web/async_chat_stream.py`
61
+
62
+
Each contains a header warning:
92
63
```text
93
64
# DO NOT EDIT THIS FILE
94
65
# 1) Modify slack_sdk/web/client.py
95
66
# 2) Run `python scripts/codegen.py`
96
67
# 3) Run `black slack_sdk/`
97
68
```
98
69
99
-
After editing `client.py` or `chat_stream.py`, always run:
70
+
**How it works:**
100
71
101
-
```sh
102
-
python scripts/codegen.py --path .
103
-
./scripts/format.sh
104
-
```
72
+
1. Edit `slack_sdk/web/client.py` (canonical source for Web API methods)
73
+
2. Edit `slack_sdk/web/chat_stream.py` (canonical source for streaming chat)
74
+
3. Run `python scripts/codegen.py --path .` to generate async/legacy variants
75
+
4. Run `./scripts/format.sh` to format the generated code
76
+
77
+
The codegen script (`scripts/codegen.py`) automatically transforms sync code into async variants by adding `async def`, `await`, and replacing classes with async equivalents.
105
78
106
79
### Web API Method Pattern
107
80
@@ -135,28 +108,27 @@ Key conventions:
135
108
136
109
### Error Types
137
110
138
-
Defined in `slack_sdk/errors/__init__.py`:
111
+
All SDK exceptions are defined in `slack_sdk/errors/__init__.py` and inherit from `SlackClientError`.
139
112
140
-
| Exception | When raised |
141
-
| --- | --- |
142
-
|`SlackClientError`| Base class for all client errors |
143
-
|`SlackApiError`| Invalid API response (carries the `response` object) |
144
-
|`SlackRequestError`| Problem submitting the request |
145
-
|`BotUserAccessError`|`xoxb` token used for a `xoxp`-only method |
-**`SlackApiError`** — Raised when the API returns an error response (carries the `response` object)
116
+
-**`SlackRequestError`** — Raised when the HTTP request itself fails
117
+
-**`BotUserAccessError`** — Raised when using a bot token (`xoxb-*`) for a user-only method
118
+
119
+
See `slack_sdk/errors/__init__.py` for the complete list of exception types and their usage.
150
120
151
121
### HTTP Retry Handlers
152
122
153
-
The `slack_sdk/http_retry/` module provides built-in retry strategies:
123
+
The `slack_sdk/http_retry/` module provides built-in retry strategies for connection errors, rate limiting (HTTP 429), and server errors (HTTP 500/503).
154
124
155
-
-**`ConnectionErrorRetryHandler`** / **`AsyncConnectionErrorRetryHandler`** — retries on connection errors
156
-
-**`RateLimitErrorRetryHandler`** / **`AsyncRateLimitErrorRetryHandler`** — retries on HTTP 429 (respects `Retry-After`)
157
-
-**`ServerErrorRetryHandler`** / **`AsyncServerErrorRetryHandler`** — retries on HTTP 500/503
125
+
Key handlers:
158
126
159
-
Retry interval is configurable via `BackoffRetryIntervalCalculator` (exponential backoff) or `FixedValueRetryIntervalCalculator`.
Retry intervals can be configured with `BackoffRetryIntervalCalculator` (exponential backoff) or `FixedValueRetryIntervalCalculator`. See `slack_sdk/http_retry/` for implementation details.
160
132
161
133
### Test Patterns
162
134
@@ -200,8 +172,9 @@ Test directories:
200
172
201
173
### Setup
202
174
203
-
A python virtual environment (`venv`) MUST be activated before running any commands. You can verify that the virtual environment is active by checking if the `$VIRTUAL_ENV` environment variable is set with `echo $VIRTUAL_ENV`.
204
-
If tools like `black`, `flake8`, `mypy`, or `pytest` are not found, ask the user to activate the venv.
175
+
**Prerequisites:** A Python virtual environment must be activated. See `.github/maintainers_guide.md` for detailed setup instructions using `pyenv` and `venv`.
176
+
177
+
**Quick check:** Verify venv is active with `echo $VIRTUAL_ENV` (should output a path).
205
178
206
179
Always use the project scripts instead of calling tools like `pytest` directly.
207
180
@@ -219,51 +192,77 @@ Installs all project dependencies (testing, optional, and tools) via pip. This s
219
192
./scripts/run_validation.sh
220
193
```
221
194
222
-
This is the canonical check — CI runs this and the PR template asks contributors to run it. It installs requirements, runs codegen, formats, lints, runs tests with coverage, and runs mypy type checking on Python 3.14.
195
+
This is the canonical check — CI runs this and the PR template asks contributors to run it. It installs requirements, runs codegen, formats, lints, runs tests with coverage, and runs mypy type checking on the latest supported Python version (check the `LATEST_SUPPORTED_PY` environment variable in `.github/workflows/ci-build.yml`).
| Generate API docs |`./scripts/generate_api_docs.sh`|
238
213
239
214
## Code Style & Tooling
240
215
241
-
-**Formatter**: `black` (line length: 125, version pinned in `requirements/tools.txt`)
242
-
-**Linter**: `flake8` (line length: 125, configured in `.flake8`)
243
-
-**Type checker**: `mypy` (configured in `pyproject.toml`, excludes `scim/` and `rtm/`)
244
-
-**Test runner**: `pytest` with `pytest-asyncio` (asyncio_mode = "auto")
216
+
All tooling configuration is defined in the following files:
217
+
218
+
-**Formatter**: `black` — see `[tool.black]` in `pyproject.toml`
219
+
-**Linter**: `flake8` — see `.flake8`
220
+
-**Type checker**: `mypy` — see `[tool.mypy]` in `pyproject.toml`
221
+
-**Test runner**: `pytest` — see `[tool.pytest.ini_options]` in `pyproject.toml`
245
222
-**Coverage**: `pytest-cov` reporting to Codecov
246
-
-**Build system**: `setuptools` via `pyproject.toml`
223
+
-**Build system**: see `[build-system]` and `[project]` in `pyproject.toml`
224
+
225
+
**Dependencies:**
226
+
227
+
- Testing: `requirements/testing.txt`
228
+
- Optional runtime: `requirements/optional.txt`
229
+
- Dev tools (black, flake8, mypy): `requirements/tools.txt`
247
230
248
231
## CI Pipeline (GitHub Actions)
249
232
250
233
Defined in `.github/workflows/ci-build.yml`, runs on push to `main`, all PRs, and daily schedule. Check the workflow file for the current Python version matrix.
0 commit comments