Repository navigation
[core] Apply ruff D212 and D200 docstring auto-fixes - #67540
Merged
Merged
Conversation
dstrodtman
requested review from
a team,
MengjinYan,
alimaazamat,
andrewsykim,
edoakes,
marosset,
richardliaw and
ryanaoleary
as code owners
October 29, 2026 13:50
Contributor
There was a problem hiding this comment.
Code Review
This pull request standardizes the formatting of docstrings across numerous files in the Ray repository. Multi-line docstrings have been updated to start the description on the same line as the opening triple quotes rather than on a new line, aligning with standard Python docstring conventions. There are no review comments, and I have no feedback to provide.
This was referenced Oct 30, 2026
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]>
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]>
dstrodtman
force-pushed
the
doc-1903-core-docstring-autofix
branch
from
November 2, 2026 20:06
1b51db7 to
06da8f9
Compare
edoakes
approved these changes
Nov 2, 2026
dstrodtman
added a commit
that referenced
this pull request
Nov 3, 2026
…tions, and ObjectRefGenerator (#67634) ## Summary Adds the missing docstrings, `Args:` entries, and `Returns:` sections on public Ray Core symbols in `ray.runtime_env.runtime_env`, `ray.exceptions`, `ray._private.object_ref_generator`, and `ray._private.ray_logging.logging_config`. Each describes existing behavior, written from the code. This PR is stacked on #67540, which applies the ruff `D212` and `D200` auto-fixes to the same files, so the new docstrings follow that format and the two PRs don't conflict. Review only the top commit. #67635 covers the rest of Ray Core. ## Before Most `RuntimeEnv` and `RuntimeEnvConfig` methods had no docstring, and several exception classes and `ObjectRefGenerator` methods had no docstring, no `Args:` entries for their constructor parameters, or no `Returns:` section. ## After - `RuntimeEnv`: `set`, `serialize`, `deserialize`, `to_dict`, and every field accessor, such as `working_dir`, `pip_config`, `conda_uri`, `py_container_image`, and `plugins`, are documented, including what each returns when its field isn't set. - `RuntimeEnvConfig`: `parse_and_validate_runtime_env_config`, `default_config`, and `to_dict` are documented. - `RayError.to_bytes`, the `RayActorError.preempted` and `actor_init_failed` properties, and the constructor parameters of `RayActorError`, `AuthenticationError`, `TaskUnschedulableError`, and `ActorUnschedulableError` are documented. `RayTaskError.make_dual_exception_instance` has a `Returns:` section. - `ObjectRefGenerator` documents its constructor parameters, `close`, and `aclose`, and `completed`, `next_ready`, and `is_finished` have `Returns:` sections. - `LoggingConfig.to_dict` and `from_dict` have `Args:` and `Returns:` sections. This PR also fixes two swapped `#:` attribute comments in `RayActorError.__init__`: the comment for `error_msg` described `actor_init_failed`, and the other way around. Autodoc renders `#:` comments as attribute docs. Behavior is unchanged. The diff touches only docstrings and comments, which the guard below confirms. ## Not in this PR - `RuntimeEnvConfig.from_proto` and `build_proto_runtime_env_config` convert to and from the protobuf message, which looks like internal plumbing rather than public API. Should they stay on the public surface? Making them private isn't a docstring-only change, so this PR leaves them alone. - `LoggingConfig` already has a class docstring, assigned through `LoggingConfig.__doc__` after the class body. A docstring in the class body would be overwritten, so nothing changes there. - `ObjectRefGenerator.send`, `throw`, `asend`, and `athrow`, `RayError.from_bytes` and `from_ray_exception`, `RuntimeEnv.get` and `get_extension`, and the constructor parameters of `CrossLanguageError`, `RayTaskError`, `RaySystemError`, `OutOfMemoryError`, and `NodeDiedError` have parameters with no type hint. Ray's pydoclint config rejects an `Args:` section until every parameter has a hint, so they need a separate PR that adds the hints and the docstrings together. ## For reviewers These are worth a close read: - `RuntimeEnv.has_conda` is annotated `-> str` but returns a bool, and `conda_env_name` and `conda_config` are annotated `-> str` but can return None. The docstrings describe what the code returns. Fixing the annotations is a code change for a separate PR. - `RuntimeEnv.conda_uri`, `pip_uri`, and `uv_uri` describe the URI as a hash of the environment spec, from the `get_uri` helpers in `ray._private.runtime_env`. `conda_uri` returns None when `conda` names an existing environment. - `RuntimeEnv.deserialize` notes that it skips validation, and `serialize` that it validates first, as the code does. ## Duplicate check No open PR documents these symbols. I searched open PRs for the module and method names. #67540, which this PR stacks on, touches the same files for docstring format only. ## Testing - `python ci/ray_ci/doc/check_docstring_only.py --base upstream/doc-1903-core-docstring-autofix`: `docstring-only guard: 4 file(s), docstrings only.` - The full pre-commit suite on the changed files, including ruff, black, pydoclint, and the docstyle hook: passed. - `uvx [email protected] check --select D212,D200,D210` on the changed files: passed, so the new docstrings don't add work for the ruff config PR. - The commit carries an `@rtd-build` line, so the Read the Docs preview renders the changed docstrings. 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]>
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]>
edoakes
pushed a commit
that referenced
this pull request
Nov 3, 2026
… them, to Ray Core public APIs (#67635) ## Summary Documents the public Ray Core symbols that are still missing docstrings, `Args:` entries, or `Returns:` sections in `ray.util`, `ray.util.queue`, `ray.util.spark`, `ray.util.tpu`, `ray.experimental`, `ray.actor`, `ray.remote_function`, `ray.types`, `ray.exceptions`, `ray.runtime_env`, `ray.runtime_context`, and `ObjectRefGenerator`. Each docstring describes existing behavior, written from the code. Some of these symbols couldn't be documented without a signature change. Ray's pydoclint config rejects an `Args:` section until every parameter has a type hint, so this PR also adds type hints to the untyped public signatures it documents. It also corrects five return annotations that didn't match what the functions return. #67540 applied the ruff `D212` and `D200` auto-fixes to these files, and #67634 documented `ray.runtime_env`, `ray.exceptions`, and `ObjectRefGenerator`. Both are merged. This PR builds on them and has two commits: the docstring additions, then the type annotations. The second commit was reviewed as #67636, which merged into this branch instead of `master`. Because the signatures change, this PR isn't docstring-only and runs the full Core premerge. ## Docstrings - `ray.util.queue`: `Empty` and `Full` are documented, and `Queue.size`, `qsize`, `empty`, and `full` have `Returns:` sections. - `ray.util.list_named_actors` documents `all_namespaces` and returns, including the dict entries it returns when `all_namespaces` is True. - `ray.util.spark.setup_global_ray_cluster` documents all 17 parameters and what it returns. Most entries follow the matching `setup_ray_cluster` parameter, which the existing docstring already says they share, and point to it for defaults and caps. - `ray.util.tpu.dispatch`, the deprecated alias of `run_on_slice`, gets `Args:` and `Returns:` sections. Adding `Returns:` makes pydoclint check `*args` and `**kwargs`, so they're documented too. - `ray.experimental`: `CompiledDAGRef.get` and the `CompiledDAGFuture` constructor parameters, the `RayActorHandleResolver` constructor and its `get`, `forget`, `list_names`, and `kill` methods, and the `ReduceOp`, `AllGatherOp`, `AllReduceOp`, `ReduceScatterOp`, and `Device` types are documented. - `ActorMethod.__call__` and `remote`, `ActorClassInheritanceException`, `RemoteFunction.__call__`, and `ray.types.ObjectRef` have docstrings. ## Type hints Type hints added, with the parameters documented in the same change: - `ObjectRefGenerator.send`, `throw`, `asend`, and `athrow`: `value: Any`. Each method only raises `NotImplementedError`, and the docstrings say so. - `RayError.from_bytes(b: bytes) -> BaseException` and `from_ray_exception(ray_exception: RayException) -> BaseException`. - The constructors of `CrossLanguageError`, `RayTaskError`, `RaySystemError`, `OutOfMemoryError`, and `NodeDiedError`. - `RuntimeContext.__init__(worker: Any)`. The worker is either the global Ray worker or Ray Client's `_ClientWorkerPropertyAPI`, which emulates it, so `Any` is the honest hint without new imports. - `RuntimeEnv.get(name: str, default: Any = None, data_class: Optional[type] = None) -> Any` and `get_extension(key: str)`. Return annotations corrected to match the code: - `RuntimeEnv.has_conda`: `str` to `bool`. - `RuntimeEnv.conda_env_name` and `conda_config`: `str` to `Optional[str]`. Both return None when `conda` isn't set or has the other form. - `RuntimeEnv.py_container_run_options`: `List` to `Optional[List]`. It returns None when `container` isn't set. - `ray.util.list_named_actors`: `List[str]` to `Union[List[str], List[Dict[str, str]]]`. With `all_namespaces=True`, it returns dicts with `name` and `namespace` keys. `AsyncioRouter` in `python/ray/serve/_private/router.py` reads `RayTaskError.cause` into a local variable before the `ActorDiedError` check instead of calling `getattr` in the condition. It returns the same value in the same cases. Type hints don't change runtime behavior. None of these files are in Ray's mypy hook. ## For reviewers CODEOWNERS adds two reviewers beyond `@ray-project/ray-core`: `@ray-project/ray-serve` for `serve/_private/router.py`, and one of the individual owners of `util/tpu.py`. These are worth a close read: - `setup_global_ray_cluster` returns the `(address, remote_connection_address)` tuple only when `is_blocking` is False. When blocking, it returns None after the cluster shuts down. - `CompiledDAGRef.get` describes the `timeout` values from `CompiledDAG._execute_until`, which it calls. `ray.get()` on a CompiledDAGRef calls this method. - `Device` describes its members from the `device` argument of `TorchTensorType`. - `RayTaskError.cause` is hinted `BaseException`, which matches what the task-execution path in `_raylet.pyx` and `CompiledDAG` pass. `actor_id` is the actor ID in hex, as `_raylet.pyx` computes it. - `RaySystemError.client_exc` is hinted `str`. The callers in `worker.py`, `serialization.py`, and `_raylet.pyx` pass a message string, despite the parameter name. - `RayError.from_bytes` and `from_ray_exception` return `BaseException`: an unpickled exception, an `UnserializableException`, or a `CrossLanguageError`. `ray.util.client.api.ClientAPI.list_named_actors` has the same `List[str]` annotation for Ray Client. It isn't public API, so this PR leaves it alone. ## Duplicate check No open PR documents these symbols or changes these signatures. I searched open PRs for the module, class, and method names. #66745 converts the `Queue` class docstring example to doctest form, which doesn't overlap the lines this PR changes. ## Testing These checks ran on each commit before the rebase onto `master`. The rebase applied both commits unchanged. - The full pre-commit suite on every changed file, including ruff, black, pydoclint, and the docstyle hook: passed. - `uvx [email protected] check --select D212,D200,D210` on the changed files: passed. - The docstring commit passed `ci/ray_ci/doc/check_docstring_only.py`. The type-annotation commit changes signatures, so it's outside that guard by design. - A smoke test against the latest nightly wheel with the type-annotated files overlaid: a task error and an actor task error round-trip through `to_bytes` and `from_bytes`, `ray.get_runtime_context()` works in the driver and in an actor, the exception constructors format their messages, `RuntimeEnv.get`, `get_extension`, and the re-annotated accessors return what their annotations now say, and the streaming generator's `send`, `throw`, `asend`, and `athrow` raise `NotImplementedError`. - `python/ray/tests/unit/test_runtime_env.py` and `test_runtime_env_validation.py` against the same overlay: 96 passed, 12 failed. The same 12 fail with `master`'s versions of those files in the same environment, because the nightly wheel's commit and the copied test fixtures don't match this checkout, so none come from this change. - Both commits carry an `@rtd-build` line, so the Read the Docs preview renders the changed docstrings. 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]>
dstrodtman
added a commit
that referenced
this pull request
Nov 4, 2026
…#67601) ## Why are these changes needed? This follows #67540, which merged on 2026-11-02 and applied ruff's `D212` and `D200` auto-fixes to `python/ray/` outside the library trees. That PR left ten `D212` violations in place because the auto-fix would change what they render as. Each has a first line indented less than the lines below it, and `inspect.cleandoc` ignores 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 on `D212`. 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.py` `report_instances` and `report_resources`, `scheduler.py` `_sort_gang_resource_requests`, `job_log_storage_client.py` `get_log_file_path`, and the `util/dask/scheduler_utils.py` module docstring get a summary line. The existing content stays below it. - `dag/dag_node.py` `DAGNode.__init__` gets a summary and a capitalized `Args:` section. The entries drop the types already in the signature, and the `ex:` 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.py` `get_docker_config`: the old text listed a "node specific docker image" as the first choice for head nodes. In `ray-schema.json`, a node type's `docker` block allows only `worker_image`, `pull_before_run`, and `worker_run_options`, so the head-node order is `head_image`, then `image`. The worker-node order now names the node type's `docker.worker_image` explicitly. - `instance_manager/config.py` `FileConfigReader` and `KubeRayConfigReader` `get_cached_autoscaling_config`: these overrides had only a `Returns:` block and no summary. They now have no docstring and inherit the abstract `IConfigReader.get_cached_autoscaling_config` docstring. - `aws/utils.py` `LazyDefaultDict.__missing__`: the pseudo-code was copied from `collections.defaultdict` and described a factory that takes no argument and a `KeyError` for a `None` factory. This override calls `default_factory(key)`, so the docstring now says that. One thing outside this PR's scope: `JobLogStorageClient.get_log_file_path` is annotated `-> Tuple[str, str]`, but it returns a single `str`. 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.` - The full pre-commit suite on the changed files, including ruff, black, pydoclint, and the docstyle hook: passed. 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]>
pawelbeza
pushed a commit
to pawelbeza/ray
that referenced
this pull request
Nov 9, 2026
… them, to Ray Core public APIs (ray-project#67635) ## Summary Documents the public Ray Core symbols that are still missing docstrings, `Args:` entries, or `Returns:` sections in `ray.util`, `ray.util.queue`, `ray.util.spark`, `ray.util.tpu`, `ray.experimental`, `ray.actor`, `ray.remote_function`, `ray.types`, `ray.exceptions`, `ray.runtime_env`, `ray.runtime_context`, and `ObjectRefGenerator`. Each docstring describes existing behavior, written from the code. Some of these symbols couldn't be documented without a signature change. Ray's pydoclint config rejects an `Args:` section until every parameter has a type hint, so this PR also adds type hints to the untyped public signatures it documents. It also corrects five return annotations that didn't match what the functions return. ray-project#67540 applied the ruff `D212` and `D200` auto-fixes to these files, and ray-project#67634 documented `ray.runtime_env`, `ray.exceptions`, and `ObjectRefGenerator`. Both are merged. This PR builds on them and has two commits: the docstring additions, then the type annotations. The second commit was reviewed as ray-project#67636, which merged into this branch instead of `master`. Because the signatures change, this PR isn't docstring-only and runs the full Core premerge. ## Docstrings - `ray.util.queue`: `Empty` and `Full` are documented, and `Queue.size`, `qsize`, `empty`, and `full` have `Returns:` sections. - `ray.util.list_named_actors` documents `all_namespaces` and returns, including the dict entries it returns when `all_namespaces` is True. - `ray.util.spark.setup_global_ray_cluster` documents all 17 parameters and what it returns. Most entries follow the matching `setup_ray_cluster` parameter, which the existing docstring already says they share, and point to it for defaults and caps. - `ray.util.tpu.dispatch`, the deprecated alias of `run_on_slice`, gets `Args:` and `Returns:` sections. Adding `Returns:` makes pydoclint check `*args` and `**kwargs`, so they're documented too. - `ray.experimental`: `CompiledDAGRef.get` and the `CompiledDAGFuture` constructor parameters, the `RayActorHandleResolver` constructor and its `get`, `forget`, `list_names`, and `kill` methods, and the `ReduceOp`, `AllGatherOp`, `AllReduceOp`, `ReduceScatterOp`, and `Device` types are documented. - `ActorMethod.__call__` and `remote`, `ActorClassInheritanceException`, `RemoteFunction.__call__`, and `ray.types.ObjectRef` have docstrings. ## Type hints Type hints added, with the parameters documented in the same change: - `ObjectRefGenerator.send`, `throw`, `asend`, and `athrow`: `value: Any`. Each method only raises `NotImplementedError`, and the docstrings say so. - `RayError.from_bytes(b: bytes) -> BaseException` and `from_ray_exception(ray_exception: RayException) -> BaseException`. - The constructors of `CrossLanguageError`, `RayTaskError`, `RaySystemError`, `OutOfMemoryError`, and `NodeDiedError`. - `RuntimeContext.__init__(worker: Any)`. The worker is either the global Ray worker or Ray Client's `_ClientWorkerPropertyAPI`, which emulates it, so `Any` is the honest hint without new imports. - `RuntimeEnv.get(name: str, default: Any = None, data_class: Optional[type] = None) -> Any` and `get_extension(key: str)`. Return annotations corrected to match the code: - `RuntimeEnv.has_conda`: `str` to `bool`. - `RuntimeEnv.conda_env_name` and `conda_config`: `str` to `Optional[str]`. Both return None when `conda` isn't set or has the other form. - `RuntimeEnv.py_container_run_options`: `List` to `Optional[List]`. It returns None when `container` isn't set. - `ray.util.list_named_actors`: `List[str]` to `Union[List[str], List[Dict[str, str]]]`. With `all_namespaces=True`, it returns dicts with `name` and `namespace` keys. `AsyncioRouter` in `python/ray/serve/_private/router.py` reads `RayTaskError.cause` into a local variable before the `ActorDiedError` check instead of calling `getattr` in the condition. It returns the same value in the same cases. Type hints don't change runtime behavior. None of these files are in Ray's mypy hook. ## For reviewers CODEOWNERS adds two reviewers beyond `@ray-project/ray-core`: `@ray-project/ray-serve` for `serve/_private/router.py`, and one of the individual owners of `util/tpu.py`. These are worth a close read: - `setup_global_ray_cluster` returns the `(address, remote_connection_address)` tuple only when `is_blocking` is False. When blocking, it returns None after the cluster shuts down. - `CompiledDAGRef.get` describes the `timeout` values from `CompiledDAG._execute_until`, which it calls. `ray.get()` on a CompiledDAGRef calls this method. - `Device` describes its members from the `device` argument of `TorchTensorType`. - `RayTaskError.cause` is hinted `BaseException`, which matches what the task-execution path in `_raylet.pyx` and `CompiledDAG` pass. `actor_id` is the actor ID in hex, as `_raylet.pyx` computes it. - `RaySystemError.client_exc` is hinted `str`. The callers in `worker.py`, `serialization.py`, and `_raylet.pyx` pass a message string, despite the parameter name. - `RayError.from_bytes` and `from_ray_exception` return `BaseException`: an unpickled exception, an `UnserializableException`, or a `CrossLanguageError`. `ray.util.client.api.ClientAPI.list_named_actors` has the same `List[str]` annotation for Ray Client. It isn't public API, so this PR leaves it alone. ## Duplicate check No open PR documents these symbols or changes these signatures. I searched open PRs for the module, class, and method names. ray-project#66745 converts the `Queue` class docstring example to doctest form, which doesn't overlap the lines this PR changes. ## Testing These checks ran on each commit before the rebase onto `master`. The rebase applied both commits unchanged. - The full pre-commit suite on every changed file, including ruff, black, pydoclint, and the docstyle hook: passed. - `uvx [email protected] check --select D212,D200,D210` on the changed files: passed. - The docstring commit passed `ci/ray_ci/doc/check_docstring_only.py`. The type-annotation commit changes signatures, so it's outside that guard by design. - A smoke test against the latest nightly wheel with the type-annotated files overlaid: a task error and an actor task error round-trip through `to_bytes` and `from_bytes`, `ray.get_runtime_context()` works in the driver and in an actor, the exception constructors format their messages, `RuntimeEnv.get`, `get_extension`, and the re-annotated accessors return what their annotations now say, and the streaming generator's `send`, `throw`, `asend`, and `athrow` raise `NotImplementedError`. - `python/ray/tests/unit/test_runtime_env.py` and `test_runtime_env_validation.py` against the same overlay: 96 passed, 12 failed. The same 12 fail with `master`'s versions of those files in the same environment, because the nightly wheel's commit and the copied test fixtures don't match this checkout, so none come from this change. - Both commits carry an `@rtd-build` line, so the Read the Docs preview renders the changed docstrings. 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]> Signed-off-by: Pawel Beza <[email protected]> Upstream-commit: 6357e3c (sandbox resolver only; unrelated API changes excluded) Co-authored-by: Copilot <[email protected]> Copilot-Session: 0baa3cf-af4e-472e-ad89-8f02c6e8be11
5 of 7 tasks
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/outside the library trees that have their own code owners (data/,serve/,train/,air/,tune/,rllib/, andllm/), which get their own PRs, 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) and collapses one-line docstrings onto one line (D200). There are noD210violations in this scope. 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 ten
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. They are inautoscaler/_private/aws/utils.py,autoscaler/v2/instance_manager/config.py(three),autoscaler/v2/metrics_reporter.py(two),autoscaler/v2/scheduler.py,dag/dag_node.py,dashboard/modules/job/job_log_storage_client.py, andutil/dask/scheduler_utils.py. They need a hand edit, which goes in a separate PR.Vendored code under
thirdparty_files/and_private/thirdparty/is untouched, because Ray's ruff config already excludes it. CODEOWNERS assigns a few files here to individual owners instead of@ray-project/ray-core:_common/,dashboard/modules/usage_stats/,util/tpu.py, and_private/accelerators/tpu.py.@edoakesis listed for all of them.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: 168 file(s), docstrings only.inspect.cleandoc(__doc__), the text Sphinx autodoc renders, is identical before and after for every docstring in the changed files: 168 files, 0 docstrings changed.--fix: the 10D212violations above remain.AI assistance (Claude Code) was used to prepare this PR.
🤖 Generated with Claude Code