Skip to content

Three docstrings type a boolean parameter as str #14723

Description

@iridescentWen

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions