Repository navigation
[doc] Move API type hints out of the signature into the Parameters list - #64779
dstrodtman wants to merge 1 commit into
Conversation
`autodoc_typehints` was set to "signature", so every parameter's full type annotation rendered inline in the class or function signature. For APIs with many parameters or long union/callable types, the signature becomes hard to scan. Switch `autodoc_typehints` to "description" and add `autodoc_typehints_description_target = "documented"`. The signature now shows just parameter names and defaults; each parameter's type moves into the Parameters list as `name (ShortType) - description`. This matches the rendering used by projects such as pandas, where signatures stay short and the type detail lives in the Parameters table. The "documented" target keeps the parameter descriptions and preserves short type names; the default "all" target would drop descriptions and render verbose typing spellings. Signed-off-by: Douglas Strodtman <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request updates the Sphinx configuration in doc/source/conf.py to move type hints from the function signatures into the description list, targeting only documented parameters. The reviewer notes that using the "documented" target will completely omit type hints for parameters that are not explicitly documented in the docstring, which may lead to a loss of type information, and suggests "all" as an alternative if type visibility for all parameters is preferred.
| # that already have a docstring entry, which keeps their prose descriptions and | ||
| # preserves short type names. | ||
| autodoc_typehints = "description" | ||
| autodoc_typehints_description_target = "documented" |
There was a problem hiding this comment.
Setting autodoc_typehints_description_target = "documented" completely omits type hints for any parameters that are not explicitly documented in the docstring, as they are removed from the signature and will not be added to the description. For APIs with partially documented or undocumented parameters, this results in a loss of type information. If type visibility for all parameters is preferred, using "all" is an alternative, though it may render undocumented parameters without descriptions.
There was a problem hiding this comment.
Good catch — this is correct, and it's the load-bearing tradeoff for this PR rather than an edge case.
autodoc_typehints = "description" strips every annotation out of the signature, and autodoc_typehints_description_target = "documented" only re-injects a type for params that already have a docstring entry. So any parameter that's annotated but undocumented renders with no type at all — it shows a type in the signature today and would lose it here.
I measured the exposure with a static pass over Ray's @PublicAPI surface at master, replicating napoleon's Args: → :param: handling and sourcing __init__ params from the class docstring (the default autoclass_content = "class"): ~21% of annotated public-API params (549/2,609) would render type-less, concentrated in Serve (~52%) and Tune (~43%). It's not obscure internals, either — the entire tune.uniform / tune.randint / tune.loguniform search-space API has prose docstrings with no Args: section, so those params would drop their types.
That's the key difference from the companion #64778 ("both"), which never drops a type. I've updated the PR description to state this cost explicitly so the move-vs-add choice is made against the number rather than on signature cleanliness alone. A third option worth noting is the sphinx-autodoc-typehints extension's always_document_param_types, which keeps a type row even for undocumented params.
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
Closing this in favor of the companion proposal, #64778, which has merged. Why the "add" approach won over the "move" approachThis PR opened as one of a pair so the two renders could be compared side by side. The comparison came down to a single question — how much type information does each mode actually erase from Ray's API reference as the docstrings exist today, not in the abstract.
A re-review before merging also turned up a second erasure this PR's description got wrong. It claimed return types simply move to a By contrast, Credit to the automated review on this PR for flagging the undocumented-parameter tradeoff early — that turned out to be the deciding axis. This isn't a rejection of short signaturesThe pandas-style render this PR proposed is still the better end state, and the preference for moving type detail out of dense signatures stands. It's gated on docstring coverage, not on the rendering approach. We're tracking the Two notes for whoever revives this:
Also verified in passing, since it affects both: the Sphinx 9 upgrade (#64944) doesn't change any of this. Sphinx 9 restructured autodoc internals, but Thanks for the review, @ronny-anyscale. |
## Why Ray's public API reference accretes undocumented parameters over time: a new `@PublicAPI` callable, or a new parameter on an existing one, can ship without a docstring `Args:` entry, and nothing fails. This adds a **static, diff-scoped** check that blocks *new* debt on the `@PublicAPI` surface while grandfathering the standing backlog. ### What pydoclint already covers, and the gap it leaves pydoclint (pinned at `0.8.3` in `.pre-commit-config.yaml`) already runs its argument-completeness checks `DOC101`/`DOC103` repo-wide across `python/ray`, against an **empty** `ci/lint/pydoclint-baseline.txt`. So that class of violation is already fully enforced with zero grandfathering, and the tree is essentially clean: a repo-wide run under the exact pre-commit config flags exactly **one** callable, `_find_imported_submodules` in vendored `python/ray/cloudpickle/cloudpickle.py`, which is private. The per-module cleanups (#63500, #63509, #63518, #63541, #63571, #63632, #63633, #63634, #63639) are what got it there. The gap is `--skip-checking-short-docstrings`, which defaults to `True` and is not overridden. It makes pydoclint skip any callable whose docstring is absent or is a bare one-line summary with no sections. Those callables can gain parameters indefinitely without any check firing. Flipping that one flag is not a viable fix. Repo-wide with `--skip-checking-short-docstrings=False`, `DOC101`/`DOC103` fire on **8,285** callables across `python/ray` (public and private alike; 16,570 violations, since each callable trips both codes) -- precisely the "baseline the size of the codebase" that the config comment on master already says the team doesn't want, and it has no `@PublicAPI` awareness to narrow it. Measured on the `@PublicAPI` surface, the same unit for comparison: of 815 public callables that take parameters, **230** have at least one undocumented parameter, totalling **505** undocumented parameters. So the public surface is roughly 3% of what a repo-wide flag flip would drag in. **All 230 of them sit in pydoclint's blind spot** -- zero overlap with what `DOC101`/`DOC103` catch today. That falls out of the numbers above without relying on any modelling of pydoclint's "short docstring" rule: if any `@PublicAPI` callable had a section-bearing docstring missing a param, pydoclint would already report `DOC101` on it, and the only such callable in the tree is a private cloudpickle function. The two checks partition the problem rather than duplicating it. This check therefore scopes exactly to the `@PublicAPI` surface with **no baseline file**: it parses the base-branch and working-tree versions of the changed files and diffs their undocumented-parameter sets, so it needs **no Ray build or import environment**. ## What it does - Enumerates the `@PublicAPI` callables changed by the PR (module-level `@PublicAPI` functions and methods of `@PublicAPI` classes). A method that carries its own `@DeveloperAPI` or `@Deprecated` is out of scope even on a public class, since it isn't part of the rendered surface; an explicit `@PublicAPI` on the method wins over both. - For each, computes the signature parameters missing from the docstring `Args:`/`Arguments:` block (for `__init__`, also the class docstring, matching the default `autoclass_content="class"`), resolving docstring inheritance so an override with no own docstring isn't flagged when a base documents the param. - Fails only on parameters that are **newly** undocumented versus the base branch. Pre-existing gaps are grandfathered; the gate fires on new public callables, newly-added params, and doc entries removed from an existing param. **Scope and limits (intentional):** all signature params, not only annotated ones. Presence only -- a param counts as documented if its name appears in `Args:`; description prose is not inspected (empty-description detection would need `numpydoc.validate` and is out of scope). Static source analysis, so it does not confirm what the reference actually renders. ## Where it lives / rollout Sits in the `ci/ray_ci/doc` guard family next to `cmd_check_api_discrepancy.py`, and runs in the **lint group** (static, no docbuild). It starts as a `soft_fail: true` step -- **visible but non-blocking** -- so the measured false-positive rate above can be confirmed against live traffic before the check gates anything. Flipping it to a required check is a one-line removal of `soft_fail`. One caveat for reviewers on the warn phase: the pipeline passes `--blocking` and relies on `soft_fail` to absorb the exit code, so an environment failure (an unfetched base branch, a shallow clone deeper than `--depth=500`) surfaces the same way a finding does. Happy to drop `--blocking` from the pipeline command instead, so the script's own warn mode carries the phase and infrastructure errors stay distinguishable from real findings. Because the check is AST-based, it matches only *directly* applied `@PublicAPI` decorators, which lines up with the direct-annotation policy established in #65196 and #65208. ## Testing - `python -m pytest ci/ray_ci/doc/test_api_param_coverage.py` -- **28 passed**. Covers new API, new param, grandfathered gap, removed doc entry, non-public / private skips, `@PublicAPI(...)` call form, `__init__`-on-class-docstring, `Args:` block termination on dedent, docstring-inheritance recovery, and the `@DeveloperAPI`/`@Deprecated`-method scoping rule. - End-to-end on the pydoclint blind spot, which is the case this check exists for: adding an undocumented `strict` param to `RayError.from_bytes` (a `@PublicAPI` method with no docstring) fired on exactly `strict`, while pydoclint under the pre-commit config reported no violations on the same file. `--blocking` exits 1; documenting the param cleared it. - End-to-end on a case pydoclint *does* cover, to confirm agreement rather than contradiction: adding an undocumented `seed` param to `tune.loguniform` fired on exactly `seed` and correctly grandfathered the pre-existing gaps in the same file. pydoclint independently blocks this one at pre-commit. - `shellcheck ci/lint/lint.sh` clean; `.buildkite/lint.rayci.yml` parses. - Renaming `python/ray/exceptions.py` with no content change reported 22 violations across 11 callables before rename detection was added, and reports none after. A rename that also adds an undocumented param still fires on exactly that param. ### False-positive rate, measured against real history Replayed the check over the **200** most recent merged commits touching `python/ray/**/*.py`, each evaluated against its own parent. **Two** fired (1%): - #64963 flagged `Dataset.map_batches_internal` with 15 parameters. A genuine false positive: the method is `@DeveloperAPI`, but the check was pulling in every non-underscore method of an `@PublicAPI` class regardless of the method's own annotation. Fixed in this PR, with regression tests; the commit is clean on the replay now. - #64519 flagged `mode`, a newly added and undocumented parameter on `Catalog.resolve` (`@PublicAPI(stability="alpha")`, one-line docstring). A true positive, and squarely the blind-spot class this check exists for. It correctly grandfathered the pre-existing `table` and `reader` gaps on the same callable. Post-fix that is **one firing across 200 commits, and it is a real finding**. ### False-negative probe Coverage was probed independently of the replay: for every `@PublicAPI` callable on the surface, inject a new undocumented keyword parameter and assert the check reports it. **815 callables probed, 0 misses** -- 585 that are currently fully documented, plus the 230 that already carry gaps, which verifies that grandfathering an existing gap doesn't mask a newly added parameter. Broken out by shape: 176 module-level functions, 470 methods, 157 `__init__`, and 12 async methods, with no misses in any group. ## Alternatives considered - **Flip `--skip-checking-short-docstrings=False` repo-wide.** 8,285 callables, no `@PublicAPI` scoping. Rejected above. - **A second pydoclint invocation with that flag plus its own baseline.** pre-commit is already diff-scoped, so this is closer than it looks, but it requires committing a baseline on the order of 8,000 entries and still gates all of `python/ray` rather than the rendered public surface. ## Relationship to other open work No open PR builds a parameter-coverage gate. #64779 changes how type hints render into the Parameters list, which is a separate deliverable and does not gate new undocumented params. ## AI assistance This change was developed with AI assistance. The submitter has reviewed every changed line and run the tests above locally. --------- Signed-off-by: Douglas Strodtman <[email protected]>
…ject#64788) ## Why Ray's public API reference accretes undocumented parameters over time: a new `@PublicAPI` callable, or a new parameter on an existing one, can ship without a docstring `Args:` entry, and nothing fails. This adds a **static, diff-scoped** check that blocks *new* debt on the `@PublicAPI` surface while grandfathering the standing backlog. ### What pydoclint already covers, and the gap it leaves pydoclint (pinned at `0.8.3` in `.pre-commit-config.yaml`) already runs its argument-completeness checks `DOC101`/`DOC103` repo-wide across `python/ray`, against an **empty** `ci/lint/pydoclint-baseline.txt`. So that class of violation is already fully enforced with zero grandfathering, and the tree is essentially clean: a repo-wide run under the exact pre-commit config flags exactly **one** callable, `_find_imported_submodules` in vendored `python/ray/cloudpickle/cloudpickle.py`, which is private. The per-module cleanups (ray-project#63500, ray-project#63509, ray-project#63518, ray-project#63541, ray-project#63571, ray-project#63632, ray-project#63633, ray-project#63634, ray-project#63639) are what got it there. The gap is `--skip-checking-short-docstrings`, which defaults to `True` and is not overridden. It makes pydoclint skip any callable whose docstring is absent or is a bare one-line summary with no sections. Those callables can gain parameters indefinitely without any check firing. Flipping that one flag is not a viable fix. Repo-wide with `--skip-checking-short-docstrings=False`, `DOC101`/`DOC103` fire on **8,285** callables across `python/ray` (public and private alike; 16,570 violations, since each callable trips both codes) -- precisely the "baseline the size of the codebase" that the config comment on master already says the team doesn't want, and it has no `@PublicAPI` awareness to narrow it. Measured on the `@PublicAPI` surface, the same unit for comparison: of 815 public callables that take parameters, **230** have at least one undocumented parameter, totalling **505** undocumented parameters. So the public surface is roughly 3% of what a repo-wide flag flip would drag in. **All 230 of them sit in pydoclint's blind spot** -- zero overlap with what `DOC101`/`DOC103` catch today. That falls out of the numbers above without relying on any modelling of pydoclint's "short docstring" rule: if any `@PublicAPI` callable had a section-bearing docstring missing a param, pydoclint would already report `DOC101` on it, and the only such callable in the tree is a private cloudpickle function. The two checks partition the problem rather than duplicating it. This check therefore scopes exactly to the `@PublicAPI` surface with **no baseline file**: it parses the base-branch and working-tree versions of the changed files and diffs their undocumented-parameter sets, so it needs **no Ray build or import environment**. ## What it does - Enumerates the `@PublicAPI` callables changed by the PR (module-level `@PublicAPI` functions and methods of `@PublicAPI` classes). A method that carries its own `@DeveloperAPI` or `@Deprecated` is out of scope even on a public class, since it isn't part of the rendered surface; an explicit `@PublicAPI` on the method wins over both. - For each, computes the signature parameters missing from the docstring `Args:`/`Arguments:` block (for `__init__`, also the class docstring, matching the default `autoclass_content="class"`), resolving docstring inheritance so an override with no own docstring isn't flagged when a base documents the param. - Fails only on parameters that are **newly** undocumented versus the base branch. Pre-existing gaps are grandfathered; the gate fires on new public callables, newly-added params, and doc entries removed from an existing param. **Scope and limits (intentional):** all signature params, not only annotated ones. Presence only -- a param counts as documented if its name appears in `Args:`; description prose is not inspected (empty-description detection would need `numpydoc.validate` and is out of scope). Static source analysis, so it does not confirm what the reference actually renders. ## Where it lives / rollout Sits in the `ci/ray_ci/doc` guard family next to `cmd_check_api_discrepancy.py`, and runs in the **lint group** (static, no docbuild). It starts as a `soft_fail: true` step -- **visible but non-blocking** -- so the measured false-positive rate above can be confirmed against live traffic before the check gates anything. Flipping it to a required check is a one-line removal of `soft_fail`. One caveat for reviewers on the warn phase: the pipeline passes `--blocking` and relies on `soft_fail` to absorb the exit code, so an environment failure (an unfetched base branch, a shallow clone deeper than `--depth=500`) surfaces the same way a finding does. Happy to drop `--blocking` from the pipeline command instead, so the script's own warn mode carries the phase and infrastructure errors stay distinguishable from real findings. Because the check is AST-based, it matches only *directly* applied `@PublicAPI` decorators, which lines up with the direct-annotation policy established in ray-project#65196 and ray-project#65208. ## Testing - `python -m pytest ci/ray_ci/doc/test_api_param_coverage.py` -- **28 passed**. Covers new API, new param, grandfathered gap, removed doc entry, non-public / private skips, `@PublicAPI(...)` call form, `__init__`-on-class-docstring, `Args:` block termination on dedent, docstring-inheritance recovery, and the `@DeveloperAPI`/`@Deprecated`-method scoping rule. - End-to-end on the pydoclint blind spot, which is the case this check exists for: adding an undocumented `strict` param to `RayError.from_bytes` (a `@PublicAPI` method with no docstring) fired on exactly `strict`, while pydoclint under the pre-commit config reported no violations on the same file. `--blocking` exits 1; documenting the param cleared it. - End-to-end on a case pydoclint *does* cover, to confirm agreement rather than contradiction: adding an undocumented `seed` param to `tune.loguniform` fired on exactly `seed` and correctly grandfathered the pre-existing gaps in the same file. pydoclint independently blocks this one at pre-commit. - `shellcheck ci/lint/lint.sh` clean; `.buildkite/lint.rayci.yml` parses. - Renaming `python/ray/exceptions.py` with no content change reported 22 violations across 11 callables before rename detection was added, and reports none after. A rename that also adds an undocumented param still fires on exactly that param. ### False-positive rate, measured against real history Replayed the check over the **200** most recent merged commits touching `python/ray/**/*.py`, each evaluated against its own parent. **Two** fired (1%): - ray-project#64963 flagged `Dataset.map_batches_internal` with 15 parameters. A genuine false positive: the method is `@DeveloperAPI`, but the check was pulling in every non-underscore method of an `@PublicAPI` class regardless of the method's own annotation. Fixed in this PR, with regression tests; the commit is clean on the replay now. - ray-project#64519 flagged `mode`, a newly added and undocumented parameter on `Catalog.resolve` (`@PublicAPI(stability="alpha")`, one-line docstring). A true positive, and squarely the blind-spot class this check exists for. It correctly grandfathered the pre-existing `table` and `reader` gaps on the same callable. Post-fix that is **one firing across 200 commits, and it is a real finding**. ### False-negative probe Coverage was probed independently of the replay: for every `@PublicAPI` callable on the surface, inject a new undocumented keyword parameter and assert the check reports it. **815 callables probed, 0 misses** -- 585 that are currently fully documented, plus the 230 that already carry gaps, which verifies that grandfathering an existing gap doesn't mask a newly added parameter. Broken out by shape: 176 module-level functions, 470 methods, 157 `__init__`, and 12 async methods, with no misses in any group. ## Alternatives considered - **Flip `--skip-checking-short-docstrings=False` repo-wide.** 8,285 callables, no `@PublicAPI` scoping. Rejected above. - **A second pydoclint invocation with that flag plus its own baseline.** pre-commit is already diff-scoped, so this is closer than it looks, but it requires committing a baseline on the order of 8,000 entries and still gates all of `python/ray` rather than the rendered public surface. ## Relationship to other open work No open PR builds a parameter-coverage gate. ray-project#64779 changes how type hints render into the Parameters list, which is a separate deliverable and does not gate new undocumented params. ## AI assistance This change was developed with AI assistance. The submitter has reviewed every changed line and run the tests above locally. --------- Signed-off-by: Douglas Strodtman <[email protected]> Signed-off-by: 400Ping <[email protected]>
…ject#64788) ## Why Ray's public API reference accretes undocumented parameters over time: a new `@PublicAPI` callable, or a new parameter on an existing one, can ship without a docstring `Args:` entry, and nothing fails. This adds a **static, diff-scoped** check that blocks *new* debt on the `@PublicAPI` surface while grandfathering the standing backlog. ### What pydoclint already covers, and the gap it leaves pydoclint (pinned at `0.8.3` in `.pre-commit-config.yaml`) already runs its argument-completeness checks `DOC101`/`DOC103` repo-wide across `python/ray`, against an **empty** `ci/lint/pydoclint-baseline.txt`. So that class of violation is already fully enforced with zero grandfathering, and the tree is essentially clean: a repo-wide run under the exact pre-commit config flags exactly **one** callable, `_find_imported_submodules` in vendored `python/ray/cloudpickle/cloudpickle.py`, which is private. The per-module cleanups (ray-project#63500, ray-project#63509, ray-project#63518, ray-project#63541, ray-project#63571, ray-project#63632, ray-project#63633, ray-project#63634, ray-project#63639) are what got it there. The gap is `--skip-checking-short-docstrings`, which defaults to `True` and is not overridden. It makes pydoclint skip any callable whose docstring is absent or is a bare one-line summary with no sections. Those callables can gain parameters indefinitely without any check firing. Flipping that one flag is not a viable fix. Repo-wide with `--skip-checking-short-docstrings=False`, `DOC101`/`DOC103` fire on **8,285** callables across `python/ray` (public and private alike; 16,570 violations, since each callable trips both codes) -- precisely the "baseline the size of the codebase" that the config comment on master already says the team doesn't want, and it has no `@PublicAPI` awareness to narrow it. Measured on the `@PublicAPI` surface, the same unit for comparison: of 815 public callables that take parameters, **230** have at least one undocumented parameter, totalling **505** undocumented parameters. So the public surface is roughly 3% of what a repo-wide flag flip would drag in. **All 230 of them sit in pydoclint's blind spot** -- zero overlap with what `DOC101`/`DOC103` catch today. That falls out of the numbers above without relying on any modelling of pydoclint's "short docstring" rule: if any `@PublicAPI` callable had a section-bearing docstring missing a param, pydoclint would already report `DOC101` on it, and the only such callable in the tree is a private cloudpickle function. The two checks partition the problem rather than duplicating it. This check therefore scopes exactly to the `@PublicAPI` surface with **no baseline file**: it parses the base-branch and working-tree versions of the changed files and diffs their undocumented-parameter sets, so it needs **no Ray build or import environment**. ## What it does - Enumerates the `@PublicAPI` callables changed by the PR (module-level `@PublicAPI` functions and methods of `@PublicAPI` classes). A method that carries its own `@DeveloperAPI` or `@Deprecated` is out of scope even on a public class, since it isn't part of the rendered surface; an explicit `@PublicAPI` on the method wins over both. - For each, computes the signature parameters missing from the docstring `Args:`/`Arguments:` block (for `__init__`, also the class docstring, matching the default `autoclass_content="class"`), resolving docstring inheritance so an override with no own docstring isn't flagged when a base documents the param. - Fails only on parameters that are **newly** undocumented versus the base branch. Pre-existing gaps are grandfathered; the gate fires on new public callables, newly-added params, and doc entries removed from an existing param. **Scope and limits (intentional):** all signature params, not only annotated ones. Presence only -- a param counts as documented if its name appears in `Args:`; description prose is not inspected (empty-description detection would need `numpydoc.validate` and is out of scope). Static source analysis, so it does not confirm what the reference actually renders. ## Where it lives / rollout Sits in the `ci/ray_ci/doc` guard family next to `cmd_check_api_discrepancy.py`, and runs in the **lint group** (static, no docbuild). It starts as a `soft_fail: true` step -- **visible but non-blocking** -- so the measured false-positive rate above can be confirmed against live traffic before the check gates anything. Flipping it to a required check is a one-line removal of `soft_fail`. One caveat for reviewers on the warn phase: the pipeline passes `--blocking` and relies on `soft_fail` to absorb the exit code, so an environment failure (an unfetched base branch, a shallow clone deeper than `--depth=500`) surfaces the same way a finding does. Happy to drop `--blocking` from the pipeline command instead, so the script's own warn mode carries the phase and infrastructure errors stay distinguishable from real findings. Because the check is AST-based, it matches only *directly* applied `@PublicAPI` decorators, which lines up with the direct-annotation policy established in ray-project#65196 and ray-project#65208. ## Testing - `python -m pytest ci/ray_ci/doc/test_api_param_coverage.py` -- **28 passed**. Covers new API, new param, grandfathered gap, removed doc entry, non-public / private skips, `@PublicAPI(...)` call form, `__init__`-on-class-docstring, `Args:` block termination on dedent, docstring-inheritance recovery, and the `@DeveloperAPI`/`@Deprecated`-method scoping rule. - End-to-end on the pydoclint blind spot, which is the case this check exists for: adding an undocumented `strict` param to `RayError.from_bytes` (a `@PublicAPI` method with no docstring) fired on exactly `strict`, while pydoclint under the pre-commit config reported no violations on the same file. `--blocking` exits 1; documenting the param cleared it. - End-to-end on a case pydoclint *does* cover, to confirm agreement rather than contradiction: adding an undocumented `seed` param to `tune.loguniform` fired on exactly `seed` and correctly grandfathered the pre-existing gaps in the same file. pydoclint independently blocks this one at pre-commit. - `shellcheck ci/lint/lint.sh` clean; `.buildkite/lint.rayci.yml` parses. - Renaming `python/ray/exceptions.py` with no content change reported 22 violations across 11 callables before rename detection was added, and reports none after. A rename that also adds an undocumented param still fires on exactly that param. ### False-positive rate, measured against real history Replayed the check over the **200** most recent merged commits touching `python/ray/**/*.py`, each evaluated against its own parent. **Two** fired (1%): - ray-project#64963 flagged `Dataset.map_batches_internal` with 15 parameters. A genuine false positive: the method is `@DeveloperAPI`, but the check was pulling in every non-underscore method of an `@PublicAPI` class regardless of the method's own annotation. Fixed in this PR, with regression tests; the commit is clean on the replay now. - ray-project#64519 flagged `mode`, a newly added and undocumented parameter on `Catalog.resolve` (`@PublicAPI(stability="alpha")`, one-line docstring). A true positive, and squarely the blind-spot class this check exists for. It correctly grandfathered the pre-existing `table` and `reader` gaps on the same callable. Post-fix that is **one firing across 200 commits, and it is a real finding**. ### False-negative probe Coverage was probed independently of the replay: for every `@PublicAPI` callable on the surface, inject a new undocumented keyword parameter and assert the check reports it. **815 callables probed, 0 misses** -- 585 that are currently fully documented, plus the 230 that already carry gaps, which verifies that grandfathering an existing gap doesn't mask a newly added parameter. Broken out by shape: 176 module-level functions, 470 methods, 157 `__init__`, and 12 async methods, with no misses in any group. ## Alternatives considered - **Flip `--skip-checking-short-docstrings=False` repo-wide.** 8,285 callables, no `@PublicAPI` scoping. Rejected above. - **A second pydoclint invocation with that flag plus its own baseline.** pre-commit is already diff-scoped, so this is closer than it looks, but it requires committing a baseline on the order of 8,000 entries and still gates all of `python/ray` rather than the rendered public surface. ## Relationship to other open work No open PR builds a parameter-coverage gate. ray-project#64779 changes how type hints render into the Parameters list, which is a separate deliverable and does not gate new undocumented params. ## AI assistance This change was developed with AI assistance. The submitter has reviewed every changed line and run the tests above locally. --------- Signed-off-by: Douglas Strodtman <[email protected]>
Context: two proposals for the same problem
The API reference signatures are hard to parse today. With
autodoc_typehints = "signature", every parameter's full type annotationrenders inline in the signature, so an API with many parameters or long
union/callable types produces a dense, hard-to-scan signature block.
There are two ways to address this, and this PR is one of a pair so reviewers
can compare the rendered result side by side:
to the Parameters list (
autodoc_typehints = "both").them only in the Parameters list (
autodoc_typehints = "description").The docs team's preference is to move the information, for the cleanest
complete render.
What changed
doc/source/conf.py:autodoc_typehints = "description"plusautodoc_typehints_description_target = "documented". The signature now showsonly parameter names and defaults; each parameter's type moves into the
Parameters list as
name (ShortType) - description. Return types move to aReturn type:field in the description.This matches the rendering used by projects such as pandas
(https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html), where the
signature stays short and the type detail lives in the Parameters table.
The
"documented"target is load-bearing: with the default"all"target,the description mode drops parameter descriptions and renders verbose
Optional[...]/Union[...]spellings instead of the short PEP 604 names.Tradeoff: undocumented parameters lose their type
The
"documented"target has a real cost, raised in review and worth statingplainly. Because
"description"strips every annotation out of the signatureand
"documented"only re-injects a type for parameters that already have adocstring entry, any parameter that's annotated but not documented renders
with no type at all. Those parameters show their type in the signature today
and would lose it under this change.
A static pass over Ray's
@PublicAPIsurface at master (replicating napoleon'sArgs:->:param:handling, and sourcing__init__params from the classdocstring under the default
autoclass_content = "class") puts this at roughly21% of annotated public-API parameters (549/2,609), concentrated in Serve
(~52%) and Tune (~43%). It isn't limited to obscure internals: the entire
tune.uniform/tune.randint/tune.loguniformsearch-space API has prosedocstrings with no
Args:section, so those parameters would drop their types.This is the key axis for comparing the two proposals. The companion #64778
(
"both") never drops a type, at the cost of longer signatures. This PR(
"description"/"documented") buys short signatures at the cost of erasingtypes from the undocumented tail. That's a defensible product stance — "show a
type only where the parameter is documented, and treat the gap as pressure to
document" — but it should be an explicit decision, and it argues for pairing the
render change with a docstring-coverage effort. A third lever, the
sphinx-autodoc-typehintsextension'salways_document_param_types, would keepa type row even for undocumented parameters.
Not a duplicate
No open PR or issue changes
autodoc_typehintsother than the companionproposal #64778, which is deliberately the alternative approach.
Testing
Rendering was validated in an isolated Sphinx 8.2.3 build (matching the docs
lock) on a class mirroring a real Ray API signature and docstring: the
signature renders with names and defaults only, and the Parameters list shows
short type names with descriptions preserved. Full-site verification is left to
this PR's Read the Docs preview build (the docs build runs
fail_on_warning: true).AI assistance
This change was prepared with AI assistance (Claude Code). The change and its
verification were reviewed by the submitter.