Repository navigation
[rllib] Apply ruff D212, D200, and D210 docstring auto-fixes - #67538
Merged
Merged
Conversation
Run ruff 0.8.4 `check --fix --unsafe-fixes --select D212,D200,D210` under the Google pydocstyle convention over python/ray/rllib/, excluding test code. The diff is formatter output only. Four docstrings keep their original layout, because moving their first line onto the quotes would change their rendered text. They need a hand edit in a separate PR. @rtd-build Signed-off-by: Douglas Strodtman <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request standardizes docstring formatting across numerous files in the RLlib codebase by moving the initial line of text to the same line as the opening triple quotes. There are no review comments, and I have no feedback to provide.
pseudo-rnd-thoughts
approved these changes
Oct 29, 2026
pseudo-rnd-thoughts
pushed a commit
that referenced
this pull request
Nov 3, 2026
…er (#67625) ## Why are these changes needed? #67538 applied ruff's `D212`, `D200`, and `D210` auto-fixes to `python/ray/rllib/`. It left four `D212` violations in place because the auto-fix would change what they render as. This PR fixes them by hand so a later config PR can turn on `D212`. Each docstring now has a summary on the opening quotes, with the existing material kept below it unchanged: - `policy/sample_batch.py` `MultiAgentBatch.size_bytes` had only a `Returns:` block. It now opens with a summary line that mirrors `SampleBatch.size_bytes`. - `models/tf/layers/multi_head_attention.py` and `models/torch/modules/multi_head_attention.py` module docstrings get a summary above the existing hanging-indent citation. - `examples/algorithms/bc/benchmark_rlunplugged_atari_pong_bc.py` module docstring gets a summary and a lead-in above the existing `schema={` block, which keeps its original indentation. For each docstring, the text `ast.get_docstring` returns before this change is an exact suffix of the text it returns after, so the only rendered change is the added summary. ## Testing - `uvx [email protected] check --select D212 --config 'lint.pydocstyle.convention="google"'` on the four changed files: all checks passed. - `python ci/ray_ci/doc/check_docstring_only.py --base upstream/master`: `docstring-only guard: 4 file(s), docstrings only.` - `pre-commit run --from-ref upstream/master --to-ref HEAD`, including ruff, black, pydoclint, and the docstyle hook: passed. No open PR covers these docstrings. `gh pr list --search "D212 rllib"` returns only the core-tree PR #67540. AI assistance (Claude Code) was used to prepare this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
Ray's code style guide says a docstring's first sentence starts on the opening quotes, and nothing enforces it yet. This PR clears ruff's auto-fixable docstring format rules from
python/ray/rllib/, including@OldAPIStackmodules, because the follow-up config PR needs every file clean, so a later config PR can turn them on without a baseline. Ruff has no baseline mechanism, so every library has to be clean first. Each library gets its own PR so that one code-owner team can review it.The diff is formatter output only. It moves summaries onto the opening quotes (
D212), collapses one-line docstrings onto one line (D200), and strips a leading space inside one docstring's quotes (D210). Nothing else changes, and no docstring text is reworded.To reproduce:
Ruff marks every
D200fix as unsafe, so--unsafe-fixesis needed to apply them. The scope guard below confirms the result changes only docstrings, and a second check confirms it doesn't change what any docstring renders as.This PR leaves four
D212violations in place, because the fix would change what those docstrings render as. Each one has a first line indented less than the lines that follow it, andinspect.cleandocignores the first line when it computes the common indent. So joining that line to the opening quotes dedents the rest of the docstring. The four are thesize_bytesdocstring inpolicy/sample_batch.py, which starts withReturns:, and the module docstrings ofmodels/tf/layers/multi_head_attention.py,models/torch/modules/multi_head_attention.py, andexamples/algorithms/bc/benchmark_rlunplugged_atari_pong_bc.py. They need a hand edit, which goes in a separate PR.Duplicate check
No open PR applies ruff
Dfixes to this code. I searched open PRs forD212,pydocstyle, anddocstring-only.Testing
python ci/ray_ci/doc/check_docstring_only.py --base "$(git merge-base upstream/master HEAD)":docstring-only guard: 90 file(s), docstrings only.inspect.cleandoc(__doc__), the text Sphinx autodoc renders, is identical before and after for every docstring in the changed files: 90 files, 0 docstrings changed.--fix: the 4D212violations above remain.AI assistance (Claude Code) was used to prepare this PR.
🤖 Generated with Claude Code