chore: add docstring formatting + linting - #1959
Conversation
Enable Ruff's pydocstyle (D) rules with the google convention and docstring-code-format, and fix the resulting violations on existing docstrings. Only the missing-docstring rules (D100-D107) and D417 (undocumented-param, almost entirely **kwargs/**others boilerplate) are ignored, so no docstrings are invented where none exist. Docstrings are reshaped to a one-line summary, a blank line before the body, and terminal punctuation. Web API method docstrings are fixed in the canonical source (slack_sdk/web/client.py) and the async/legacy clients are regenerated via scripts/codegen.py. Legacy slack/ package docstrings are fixed too. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1959 +/- ##
==========================================
+ Coverage 84.10% 84.13% +0.02%
==========================================
Files 118 118
Lines 13553 13553
==========================================
+ Hits 11399 11403 +4
+ Misses 2154 2150 -4 ☔ View full report in Codecov by Harness. |
The D205/D212/D415 autofix truncated two wrapped-sentence docstrings in basic_components.py (Option.__init__, OptionGroup.__init__). Reflow them into a proper summary + body; stays lint-green under the google convention. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
ContainerBlock (#1949) landed on main before the D-rules were enabled and was merged into this branch, tripping D205/D415. Add the blank line after the summary so `ruff check` passes tree-wide. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
zimeg
left a comment
There was a problem hiding this comment.
@WilliamBergamin The health of code is better with these changes. Thanks true immense. I leave comments but nothing blocking.
| class SignatureVerifier: | ||
| def __init__(self, signing_secret: str, clock: Clock = Clock()): | ||
| """Slack request signature verifier | ||
| """Slack request signature verifier. |
There was a problem hiding this comment.
🌟 praise: I'm so glad this can be enforced with linting.
| """ | ||
| Use the select element for multiple choice selections allowing users to pick a | ||
| single item from a list. True to web roots, this selection is displayed as a | ||
| """Use the select element for multiple choice selections allowing users to pick a single item from a list. |
There was a problem hiding this comment.
🌲 praise: Big fan of infinite line lengths to let editors wrap however preferred.
| ignore = [ | ||
| # missing-docstring: do not add docstrings where none exist | ||
| "D100", | ||
| "D101", | ||
| "D102", | ||
| "D103", | ||
| "D104", | ||
| "D105", | ||
| "D106", | ||
| "D107", | ||
| # undocumented-param: 51/54 cases are just **others/**kwargs boilerplate in Block Kit models | ||
| "D417", | ||
| ] |
There was a problem hiding this comment.
👁️🗨️ question: Do we have a goal to remove these over time?
There was a problem hiding this comment.
Yess the goal is to remove them but it would introduce to many breaking changes
Summary
Ports bolt-python #1567 to this repo: enables Ruff's pydocstyle rules with the google convention and
docstring-code-format, and fixes the resulting violations on existing docstrings rather than suppressing them.Note on the legacy
slack/packageslack/is normally in maintenance mode, but these changes are cosmetic (docstring-only) and it is already inside theruff checkscope, so its docstrings are fixed too rather than excluded.Content-defect pass
The mechanical D205 (blank-line-after-summary) + D415 (terminal-period) fixes can split a single sentence that was wrapped across multiple physical lines into a grammatically broken summary + orphaned body. Those were hand-reflowed into a proper summary + body (mirrors bolt #1567's second commit).
Verification
ruff check slack/ slack_sdk/→ All checks passed (E501 confirms every reflow stays ≤125)ruff format --check→ idempotentpython scripts/codegen.py --path .→ re-running leaves the generated trio unchanged (source/generated in sync)mypy→ Success, no issues found in 107 source filestests/slack_sdk/models/→ 326 passed; import smoke across sync/async/legacy clientsFollow-up
After merge, add the squash-merge SHA to
.git-blame-ignore-revssogit blameskips this sweep (mirrors bolt).🤖 Generated with Claude Code