Skip to content

Fix mutable default list argument in config classes#384

Open
hobostay wants to merge 1 commit intomicrosoft:mainfrom
hobostay:fix/mutable-default-args
Open

Fix mutable default list argument in config classes#384
hobostay wants to merge 1 commit intomicrosoft:mainfrom
hobostay:fix/mutable-default-args

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented May 4, 2026

Summary

  • Fix mutable default argument encoder_ratios=[8,5,5,4,2,2] in VibeVoiceAcousticTokenizerConfig and VibeVoiceSemanticTokenizerConfig
  • Python evaluates default arguments once at class definition time, so all instances share the same list object
  • Mutating the list on one instance (e.g., via .append(), .sort()) would silently corrupt all other instances
  • Also use list(encoder_ratios) when assigning decoder_ratios to avoid shared references

Details

Affected file: vibevoice/modular/configuration_vibevoice.py (lines 55, 118)

Changed encoder_ratios: Optional[List[int]] = [8,5,5,4,2,2] to encoder_ratios: Optional[List[int]] = None with if encoder_ratios is None: encoder_ratios = [8, 5, 5, 4, 2, 2] inside the method body. This is a well-known Python pitfall.

Test plan

  • Verify configs can still be instantiated without arguments (default values preserved)
  • Verify mutations on one config instance don't affect others

🤖 Generated with Claude Code

Replace mutable default `encoder_ratios=[8,5,5,4,2,2]` with `None`
and initialize inside the method body. Python evaluates default
arguments once at class definition time, so all instances share the
same list object. Mutating it on one instance would silently corrupt
all others.

Also use `list(encoder_ratios)` when assigning `decoder_ratios` from
`encoder_ratios` to avoid shared references between encoder and decoder.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant