Skip to content

Fix: update type hints for Tuple parameters across multiple files to support variable-length tuples - #12544

Merged
stevhliu merged 2 commits into
huggingface:mainfrom
cesaryuan:fix-types
Nov 10, 2025
Merged

Fix: update type hints for Tuple parameters across multiple files to support variable-length tuples#12544
stevhliu merged 2 commits into
huggingface:mainfrom
cesaryuan:fix-types

Conversation

@cesaryuan

Copy link
Copy Markdown
Contributor

What does this PR do?

Many classes exhibit the issues present in #4806, but these have not been fixed or reported. This PR attempts to resolve a batch of similar issues.

Fixes all issues like #4806

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@yiyixuxu
yiyixuxu requested a review from CopilotOctober 28, 2025 02:37

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes type hint inconsistencies across multiple files by updating Tuple type annotations to use variable-length syntax (Tuple[type, ...]) where parameters accept tuples of arbitrary length. This addresses issues similar to #4806 where fixed-length tuple annotations were incorrectly used for parameters that should accept variable-length tuples.

Key changes:

  • Updated type hints from Tuple[str] to Tuple[str, ...] for block type parameters
  • Updated type hints from Tuple[int] to Tuple[int, ...] for channel configuration parameters
  • Fixed one incorrect annotation from Tuple[str] to str for a non-tuple parameter

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/diffusers/pipelines/shap_e/renderer.pyUpdated tuple type hints for param_names, param_shapes, and background parameters
src/diffusers/pipelines/deprecated/versatile_diffusion/modeling_text_unet.pyFixed type hints for down_block_types, up_block_types, and block_out_channels
src/diffusers/pipelines/audioldm2/modeling_audioldm2.pyUpdated block type and channel configuration tuple hints
src/diffusers/models/vae_flax.pyFixed type hints across Encoder, Decoder, and AutoencoderKL classes
src/diffusers/models/unets/unet_stable_cascade.pyUpdated tuple hints for block channels, attention heads, and layer configuration
src/diffusers/models/unets/unet_spatio_temporal_condition.pyFixed block type and configuration parameter type hints
src/diffusers/models/unets/unet_kandinsky3.pyUpdated block_out_channels type hint
src/diffusers/models/unets/unet_2d_condition.pyFixed type hints in both init and _check_config methods
src/diffusers/models/unets/unet_1d.pyUpdated block type and channel hints, corrected mid_block_type from Tuple to str
src/diffusers/models/transformers/transformer_wan_vace.pyFixed patch_size type hint
src/diffusers/models/transformers/transformer_wan.pyFixed patch_size type hint
src/diffusers/models/transformers/transformer_skyreels_v2.pyFixed patch_size type hint
src/diffusers/models/transformers/transformer_hunyuanimage.pyUpdated rope_axes_dim type hint
src/diffusers/models/transformers/transformer_hunyuan_video_framepack.pyUpdated rope_axes_dim type hint
src/diffusers/models/transformers/transformer_hunyuan_video.pyUpdated rope_axes_dim type hint
src/diffusers/models/controlnets/controlnet_xs.pyFixed multiple tuple type hints for conditioning and block parameters
src/diffusers/models/autoencoders/autoencoder_kl_wan.pyUpdated dim_mult type hint and changed default from list to tuple
src/diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.pyFixed block configuration type hints
src/diffusers/models/autoencoders/autoencoder_kl_qwenimage.pyUpdated dim_mult type hint and changed default from list to tuple
src/diffusers/models/autoencoders/autoencoder_kl_mochi.pyFixed encoder and decoder block channel type hints
src/diffusers/models/autoencoders/autoencoder_kl_hunyuanimage_refiner.pyUpdated block_out_channels type hint
src/diffusers/models/autoencoders/autoencoder_kl_hunyuan_video.pyFixed block_out_channels type hint
src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.pyUpdated block type and channel configuration hints
src/diffusers/models/autoencoders/autoencoder_kl.pyFixed encoder and decoder block type hints
src/diffusers/models/autoencoders/autoencoder_dc.pyUpdated multiple tuple hints including qkv_mutliscales, block_out_channels, and layers_per_block
examples/community/pipeline_faithdiff_stable_diffusion_xl.pyFixed block type and channel configuration type hints
examples/community/matryoshka.pyUpdated type hints in both init and _check_config methods
examples/community/img2img_inpainting.pyFixed paste_offset type hint

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsrc/diffusers/models/autoencoders/autoencoder_kl_wan.py
Comment threadsrc/diffusers/models/unets/unet_1d.py
@yiyixuxu

Copy link
Copy Markdown
Collaborator

@bot /style

@github-actions

github-actionsBot commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

Style bot fixed some files and pushed the changes.

@yiyixuxuyiyixuxu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks!

@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.

@stevhliustevhliu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@stevhliu
stevhliu merged commit 5a47442 into huggingface:mainNov 10, 2025
23 of 28 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@cesaryuan@yiyixuxu@HuggingFaceDocBuilderDev@stevhliu