Skip to content

[WIP] chore: add utilities to check if call/forward methods are documented.#13758

Merged
sayakpaul merged 6 commits into
mainfrom
forward-call-checking
May 21, 2026
Merged

[WIP] chore: add utilities to check if call/forward methods are documented.#13758
sayakpaul merged 6 commits into
mainfrom
forward-call-checking

Conversation

@sayakpaul
Copy link
Copy Markdown
Member

@sayakpaul sayakpaul commented May 15, 2026

What does this PR do?

To have some much-needed consistency in our docstrings where it should matter.

The diff seems large because of the docstring stuff. Main stuff is under .github/workflows/, utils/check_forward_call_docstrings.py, and Makefile.

@github-actions github-actions Bot added CI size/L PR with diff > 200 LOC labels May 15, 2026
@sayakpaul sayakpaul requested a review from stevhliu May 19, 2026 05:19
Copy link
Copy Markdown
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

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

very nice!

should we run the checker locally and see what pops up and include the cleanups here before landing this pr?

@sayakpaul
Copy link
Copy Markdown
Member Author

should we run the checker locally and see what pops up and include the cleanups here before landing this pr?

We can actually run python utils/check_forward_call_docstrings.py locally to get a list of what needs fixing. The CI is also reporting those.

Do we want to fix them in this PR?

@stevhliu
Copy link
Copy Markdown
Member

oh i see it now, wow this is really handy! i'm ok with either fixing here or in separate pr :)

@sayakpaul
Copy link
Copy Markdown
Member Author

i'm ok with either fixing here or in separate pr :)

Do you maybe want to branch off of this PR branch and open a PR to this one with the fixes?

@sayakpaul sayakpaul marked this pull request as ready for review May 20, 2026 06:35
@sayakpaul sayakpaul requested review from DN6, stevhliu and yiyixuxu May 20, 2026 06:35
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Copy Markdown
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

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

thanks,
not merge-blocking, but I think, it could make a better developer experience if we also add a placeholder entry for missing arg & remove the ones not exist

from pathlib import Path


REPO_ROOT = Path(__file__).resolve().parents[1]
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot May 20, 2026

Choose a reason for hiding this comment

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

Claude finished @yiyixuxu's task in 9m 42s —— View job


Adding --fix option to check_forward_call_docstrings.py

  • Read and understand the existing script
  • Implement --fix option that adds placeholders for missing args and removes non-existing args
  • Verify implementation
  • Commit changes

Summary

Added a --fix flag to utils/check_forward_call_docstrings.py that automatically fixes docstring/signature mismatches:

Usage:

python utils/check_forward_call_docstrings.py --fix
# Or for specific files:
python utils/check_forward_call_docstrings.py --fix --paths src/diffusers/models/transformers/transformer_flux.py

What it does:

  1. Missing arguments — adds a placeholder entry (arg_name: TODO - add description.) to the Args section. If no Args section exists, one is created.
  2. Stale arguments — removes documentation entries for arguments that no longer exist in the method signature.

New functions added:

  • _get_docstring_node() — locates the AST node for a method's docstring
  • _find_args_section_in_source() — finds the Args section boundaries in raw source lines
  • _parse_entry_ranges() — parses individual arg entries with their line ranges for clean removal/preservation
  • fix_file() — orchestrates the fixes for a single file, applying changes in reverse source order to preserve line numbers

@yiyixuxu
Copy link
Copy Markdown
Collaborator

yiyixuxu commented May 20, 2026

(testing , ignore us....)

@claude can you open a PR to add an option "--fix" that:

  1. add a placeholder for missing argument
  2. remove the non-existing argument

COMMIT THIS

@github-actions
Copy link
Copy Markdown
Contributor

ℹ️ COMMIT THIS was requested, but Claude didn't edit any files under .ai/ or src/diffusers/, so no follow-up PR was opened. See workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

Claude finished @yiyixuxu's task in 9m 53s —— View job


Adding --fix option to check_forward_call_docstrings.py

  • Read and understand the existing script
  • Implement --fix option that adds placeholders for missing args and removes non-existing args
  • Verify implementation
  • Commit changes

Summary

Added a --fix flag to utils/check_forward_call_docstrings.py that automatically fixes docstring/signature mismatches:

Usage:

python utils/check_forward_call_docstrings.py --fix
# Or for specific files:
python utils/check_forward_call_docstrings.py --fix --paths src/diffusers/models/transformers/transformer_flux.py

What it does:

  1. Missing arguments — adds a placeholder entry (arg_name: TODO - add description.) to the Args section. If no Args section exists, one is created.
  2. Stale arguments — removes documentation entries for arguments that no longer exist in the method signature.

New functions added:

  • _get_docstring_node() — locates the AST node for a method's docstring
  • _find_args_section_in_source() — finds the Args section boundaries in raw source lines
  • _parse_entry_ranges() — parses individual arg entries with their line ranges for clean removal/preservation
  • fix_file() — orchestrates the fixes for a single file, applying changes in reverse source order to preserve line numbers

@github-actions
Copy link
Copy Markdown
Contributor

ℹ️ COMMIT THIS was requested, but Claude didn't edit any files under .ai/ or src/diffusers/, so no follow-up PR was opened. See workflow run.

@sayakpaul sayakpaul merged commit f502538 into main May 21, 2026
19 of 20 checks passed
@sayakpaul sayakpaul deleted the forward-call-checking branch May 21, 2026 02:30
Enderfga added a commit to Enderfga/diffusers that referenced this pull request May 21, 2026
…all_docstrings

main huggingface#13758 added utils/check_forward_call_docstrings.py which requires every signature
arg to appear as its own `name (...):` entry under Args:. Expand the bidi and FAR
transformer forward docstrings to list each parameter individually.
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.

4 participants