huggingface / huggingface/diffusers
Three docstrings type a boolean parameter as str
- Langage dominant
- Python
- Étoiles
- 34.5k
- Forks
- 7.3k
- Merge moyen
- 3 j 3 h
- PR mergées (30 j)
- 91
Description
### 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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par les trois emplacements documentés : src/diffusers/pipelines/pipeline_utils.py, src/diffusers/modular_pipelines/modular_pipeline.py et src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py. Comparez chaque entrée de paramètre avec la signature et l’utilisation correspondantes à proximité. Le travail est terminé lorsque les trois docstrings décrivent les paramètres booléens de manière cohérente dans la documentation de référence générée, sans modifier le comportement à l’exécution.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- documentation
- Type d'issue
- Documentation
- Difficulté
- 1/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 25/100