huggingface / huggingface/diffusers

Three docstrings type a boolean parameter as str

オープン
#14,723 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug modular-pipelines needs-env-info pipelines
主要言語
Python
スター
34.5k
フォーク
7.3k
平均マージ
3日 3時間
マージ済み PR(30日)
91

説明

Describe the bug

Three docstrings annotate a boolean parameter as `str`. Each is self-contradictory on its own
line, since it pairs the str type with a boolean default:

Location Docstring says Real type
src/diffusers/pipelines/pipeline_utils.py:423 silence_dtype_warnings (`str`, *optional*, defaults to `False`) bool
src/diffusers/modular_pipelines/modular_pipeline.py:2612 same line, same parameter bool
src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py:1213 from_safetensors (`str`, *optional*, defaults to `False`) bool (:1156 from_safetensors: bool = False)

Evidence for each, from the surrounding code rather than from the parameter names:

  • silence_dtype_warnings — the same docstring's own signature examples three lines above
    (pipeline_utils.py:408, :410, :412) all write silence_dtype_warnings=False. It is read as
    kwargs.pop("silence_dtype_warnings", False) (:431), used as a plain condition (:588
    and not silence_dtype_warnings), and internal callers pass True (:1230, :1344). The prose
    right below it also reads "Whether to omit warnings…", which is boolean phrasing.
  • from_safetensors — annotated bool = False at :1156 and used as a bare condition at
    :1269. The very next docstring entry, load_safety_checker (bool, *optional*, defaults to True),
    is the correct spelling of the same shape.

Documentation only; no runtime behavior is affected. It is misleading for anyone reading the
reference docs, since str implies passing "False" — which is truthy.

Reproduction
import inspect, re
from diffusers import DiffusionPipeline

doc = DiffusionPipeline.to.__doc__
print(re.search(r"silence_dtype_warnings \(`(\w+)`", doc).group(1))   # str
print(inspect.signature(DiffusionPipeline.to))                        # **kwargs; default is False
Logs

No response

System Info

Documentation-only issue, read from main.

Who can help?

@stevhliu

Note

A fix is already open as a PR linked to this issue — three one-line edits, strbool. Filing
this because of the pr-link-issue reminder; not looking for anyone else to pick it up.

Found with an AST pass comparing each documented parameter type against its real annotation, which
reports only unambiguous simple-type contradictions (containers, unions, unannotated params, and
bool/int style differences are all skipped). It finds 0 further instances in src/diffusers
after this change.

Related but deliberately not in that PR, since it is a different problem class and would touch 19
files: 27 docstrings write a boolean default as a quoted string, e.g.
force_zeros_for_empty_prompt (`bool`, *optional*, defaults to `"True"`) in
pipeline_controlnet_sd_xl.py:222 where the signature is bool = True. Happy to send that as a
follow-up, per family or in one batch — your call on how you'd like it split.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、文書化されている次の3か所から始めます: src/diffusers/pipelines/pipeline_utils.py、src/diffusers/modular_pipelines/modular_pipeline.py、src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py。各パラメータエントリを、近くにあるシグネチャおよび使用箇所と比較します。生成されたリファレンスドキュメントで、3つすべてのdocstringがbooleanパラメータを一貫して説明しており、ランタイムの動作を変更していなければ完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
documentation
issue の種類
ドキュメント
難易度
1/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。