huggingface / huggingface/diffusers

Three docstrings type a boolean parameter as str

Offen
#14,723 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug modular-pipelines needs-env-info pipelines
Vorherrschende Sprache
Python
Sterne
34.5k
Forks
7.3k
Ø Merge
3 T. 3 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### 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

```python
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, `str` → `bool`. 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with the three documented locations: src/diffusers/pipelines/pipeline_utils.py, src/diffusers/modular_pipelines/modular_pipeline.py, and src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py. Compare each parameter entry with its nearby signature and usage. Done means all three docstrings describe the boolean parameters consistently in the generated reference documentation, without changing runtime behavior.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
1/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.