Repository navigation
[core] Hand-fix the ten D212 docstrings the auto-fix would mis-render - #67601
Merged
Merged
Conversation
Run ruff 0.8.4 `check --fix --unsafe-fixes --select D212,D200,D210` under the Google pydocstyle convention over python/ray/, excluding the library trees with their own code owners (data, serve, train, air, tune, rllib, llm), test code, and generated code. The diff is formatter output only. Ten 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]>
Give each docstring a summary on the opening quotes and re-indent the material below it as a block or section, so the D212 rule can be turned on without changing what these docstrings render as. Where the existing text disagreed with the code, the text now follows the code: get_docker_config's head-node image order, and LazyDefaultDict.__missing__, whose copied defaultdict pseudo-code described a different factory signature. The two get_cached_autoscaling_config overrides drop their summary-less docstrings and inherit IConfigReader's. @rtd-build Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request focuses on cleaning up, formatting, and improving docstrings across various modules, including the autoscaler, DAG node, dashboard, and scheduler utilities. A review comment suggests a minor phrasing improvement in the DAG node initialization docstring to clarify that ClassMethodNode is a subclass implementation rather than a bound keyword argument.
Comment on lines
+58
to
+60
| other_args_to_resolve: Bound kwargs to resolve that are specific | ||
| to a subclass implementation, without exposing them as args | ||
| in the base class. For example, ``ClassMethodNode``. |
Contributor
There was a problem hiding this comment.
The phrasing "For example, ClassMethodNode" is slightly ambiguous because ClassMethodNode is a subclass implementation rather than a bound keyword argument. Clarifying this to "For example, in ClassMethodNode" or "such as in ClassMethodNode" improves readability.
Suggested change
| other_args_to_resolve: Bound kwargs to resolve that are specific | |
| to a subclass implementation, without exposing them as args | |
| in the base class. For example, ``ClassMethodNode``. | |
| other_args_to_resolve: Bound kwargs to resolve that are specific | |
| to a subclass implementation, without exposing them as args | |
| in the base class. For example, in 'ClassMethodNode'. |
MortalHappiness
approved these changes
Oct 31, 2026
pseudo-rnd-thoughts
added a commit
that referenced
this pull request
Nov 2, 2026
## Why are these changes needed? The ruff pre-commit hook is pinned to v0.8.4 (Dec 2024). This bumps it to v0.17.3 without changing what gets linted, so we can later opt into newer rules (e.g. `ASYNC`, `RUF100`) one group at a time. - `.pre-commit-config.yaml`: `rev: v0.8.4` → `rev: v0.17.3`. - `pyproject.toml`: newer ruff enables a much larger default rule set (413 enabled rules under our config vs 109 on 0.8.4, ~40k findings). Because our config only uses `extend-select`, I pinned `select = ["E4", "E7", "E9", "F"]` (the old defaults) to keep behaviour unchanged. - `pyproject.toml`: ignored `C420` (unnecessary dict comprehension), a C4 rule added after 0.8.4. It flags 71 existing sites across rllib, serve, data, tune, train, dag and the dashboard. All are auto-fixable, so it can be enabled with `--fix` in a follow-up rather than pinging every CODEOWNER here. No Python source changes. ## Duplicate check `gh pr list --state open --search "ruff"` turns up #67540 and #67601, which apply ruff docstring fixes to source files. Neither changes the ruff version, `.pre-commit-config.yaml` or `pyproject.toml`, so this doesn't overlap with them. ## Testing Run over all tracked `.py`/`.pyi` files except `doc/` and `python/ray/cloudpickle/` (both already have violations on 0.8.4), with `--force-exclude` as the hook uses: - `[email protected] check --force-exclude` (main hook): passes, 0 findings (0.8.4 on master: also 0). - `[email protected] check --force-exclude --select I` (import-sort hook): 1 finding in `python/ray/_private/runtime_env/_clonevirtualenv.py`, the same as on 0.8.4, so it already exists. - `pre-commit run check-toml --files pyproject.toml`: passes. Ruff 0.17.3 also prints a non-fatal warning about two existing `# noqa: type` comments in `python/ray/data/_internal/planner/plan_all_to_all_op.py`. I left them unchanged here. I haven't run `pre-commit run --all-files`. ## AI assistance AI assistance (Claude Code) was used to measure the findings and make this change. I reviewed the diff. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Mark Towers <[email protected]> Co-authored-by: Mark Towers <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
dstrodtman
force-pushed
the
doc-1903-core-docstring-autofix
branch
from
November 2, 2026 20:06
1b51db7 to
06da8f9
Compare
dstrodtman
requested review from
MengjinYan,
alimaazamat,
andrewsykim,
edoakes,
marosset,
richardliaw and
ryanaoleary
as code owners
November 2, 2026 20:06
…string-fixes Signed-off-by: Douglas Strodtman <[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?
This follows #67540, which merged on 2026-11-02 and applied ruff's
D212andD200auto-fixes topython/ray/outside the library trees. That PR left tenD212violations in place because the auto-fix would change what they render as. Each has a first line indented less than the lines below it, andinspect.cleandocignores the first line when it computes the common indent, so joining that line to the opening quotes dedents the rest. This PR fixes them by hand so a later config PR can turn onD212.Each docstring now has a summary on the opening quotes, with the material below it re-indented as a block or section. Every summary comes from the existing text or from the code:
metrics_reporter.pyreport_instancesandreport_resources,scheduler.py_sort_gang_resource_requests,job_log_storage_client.pyget_log_file_path, and theutil/dask/scheduler_utils.pymodule docstring get a summary line. The existing content stays below it.dag/dag_node.pyDAGNode.__init__gets a summary and a capitalizedArgs:section. The entries drop the types already in the signature, and theex:lines become "For example,...".Three docstrings changed beyond layout, because the existing text didn't match the code. These need a close read:
instance_manager/config.pyget_docker_config: the old text listed a "node specific docker image" as the first choice for head nodes. Inray-schema.json, a node type'sdockerblock allows onlyworker_image,pull_before_run, andworker_run_options, so the head-node order ishead_image, thenimage. The worker-node order now names the node type'sdocker.worker_imageexplicitly.instance_manager/config.pyFileConfigReaderandKubeRayConfigReaderget_cached_autoscaling_config: these overrides had only aReturns:block and no summary. They now have no docstring and inherit the abstractIConfigReader.get_cached_autoscaling_configdocstring.aws/utils.pyLazyDefaultDict.__missing__: the pseudo-code was copied fromcollections.defaultdictand described a factory that takes no argument and aKeyErrorfor aNonefactory. This override callsdefault_factory(key), so the docstring now says that.One thing outside this PR's scope:
JobLogStorageClient.get_log_file_pathis annotated-> Tuple[str, str], but it returns a singlestr. Fixing the annotation is a code change, so it's in #67602 instead.Testing
uvx [email protected] check --select D212 --config 'lint.pydocstyle.convention="google"'on the seven changed files: all checks passed.python ci/ray_ci/doc/check_docstring_only.py --base doc-1903-core-docstring-autofix:docstring-only guard: 7 file(s), docstrings only.AI assistance (Claude Code) was used to prepare this PR.
🤖 Generated with Claude Code