Skip to content

docs: drop Returns sections from functions that return nothing - #6146

Open
VenishPaneliya wants to merge 1 commit into
deepmodeling:masterfrom
VenishPaneliya:docs-constructor-returns
Open

VenishPaneliya wants to merge 1 commit into
deepmodeling:masterfrom
VenishPaneliya:docs-constructor-returns

Conversation

@VenishPaneliya

@VenishPaneliya VenishPaneliya commented Nov 19, 2026 •

Copy link
Copy Markdown

Three docstrings in deepmd document a Returns section for a function that is annotated -> None and has no return statement, so numpydoc renders a Returns block on an object that never produces one.

  • DescrptDPA2.__init__ in both the PyTorch and the Paddle backend carries a copy of forward's Returns block (descriptor, g2, h2, rot_mat, sw). forward already documents those outputs itself, and in more detail, so the constructor copy is redundant as well as wrong.
  • Spin.build documents embedded_types; it builds TensorFlow constants inside a variable scope and returns nothing.

AutoAPI renders all of deepmd/, so all three show up in the API reference today.

Docstrings only, no behaviour change. A small AST check over the three functions reports 3 failures before and 0 after, and ruff check / ruff format --check pass on the three files.

Summary by CodeRabbit

  • Documentation
    • Removed the Returns sections from documentation for the DPA2 descriptor in the PyTorch and TensorFlow interfaces, and from the spin-building documentation. These sections previously described descriptor outputs, intermediate tensors, and embedded types. No public APIs or runtime behavior changed.

Three docstrings in `deepmd` document a `Returns` section for a function
annotated `-> None` that has no return statement, so numpydoc renders a
Returns block on an object that never produces one.

- `DescrptDPA2.__init__` in both the PyTorch and the Paddle backend
  carries a copy of `forward`'s Returns block (descriptor, g2, h2,
  rot_mat, sw). `forward` already documents those outputs itself, and in
  more detail, so the constructor copy is redundant as well as wrong.
- `Spin.build` documents `embedded_types`; it builds TensorFlow constants
  inside a variable scope and returns nothing.

Docstrings only; no behaviour change.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The pull request removes the Returns sections from the DPA2 constructor docstrings in the PyTorch and Paddle implementations, and from Spin.build in the TensorFlow utilities.

Changes: Docstring edits

Layer / File(s) Summary
Remove Returns sections
deepmd/pd/model/descriptor/dpa2.py, deepmd/pt/model/descriptor/dpa2.py, deepmd/tf/utils/spin.py
The DPA2 constructor docstrings and Spin.build docstring no longer include Returns sections.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Change: Other

Suggested reviewers: iprozd, hydrogensulfate, hztttt

Merge Risk: Minimal · up to 8ed4d

This change only edits documentation in three docstrings and does not alter runtime behavior, so it is safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: the docs commit removes Returns sections from docstrings of functions that return nothing. The changeset removes a Returns section from DescrptDPA2.init in the Pa…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: the docs commit removes Returns sections from docstrings of functions that return nothing. The changeset removes a Returns section from DescrptDPA2.init in the Paddle backend, from DescrptDPA2.init in the PyTorch backend, and from Spin.build in the TensorFlow backend. The title names the docs type and the intent, so it matches the change. It is specific enough for a teammate scanning history.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f187a83a-e2f2-4a2a-9ca0-7cd16ffa136e
Commits

Reviewing files that changed from the base of the PR and between ed85942 and 8ed4df2.

Files selected for processing: 3

  • deepmd/pd/model/descriptor/dpa2.py
  • deepmd/pt/model/descriptor/dpa2.py
  • deepmd/tf/utils/spin.py
Files with no reviewable changes: 3

  • deepmd/pd/model/descriptor/dpa2.py
  • deepmd/pt/model/descriptor/dpa2.py
  • deepmd/tf/utils/spin.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@wanghan-iapcm wanghan-iapcm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs-only cleanup: the PR deletes a numpydoc Returns section from three docstrings that belong to callables producing no value — DescrptDPA2.__init__ in the PyTorch and Paddle backends (both annotated -> None; the deleted text was a stale, wrongly ordered copy of forward's five-output list) and deepmd.tf.utils.spin.Spin.build (which only creates three tf.constant nodes under spin_attr<suffix> and never returned the documented embedded_types). I verified the premise against the bodies and return annotations at head: all three deletions are correct, forward's own Returns block in pt and pd is intact, and no code or behaviour changes.

One non-blocking note on the stated rationale: with the pinned sphinx-autoapi 3.8.0 defaults (autoapi_python_class_content="class", PythonMethod._should_skip excludes __init__, and doc/conf.py sets no override), the two edited __init__ docstrings are never rendered, while the rendered DescrptDPA2 class docstring in deepmd/dpmodel still carries the identical wrong Returns block. The cleanup is correct but does not change a rendered page; removing the dpmodel class-docstring copy as well would make the fix land where it is published. Not a reason to hold the PR.

Approving.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants