Skip to content

fix: Use Optional[T] for nullable type annotation defaults#325

Open
kuishou68 wants to merge 3 commits into
OpenBMB:mainfrom
kuishou68:fix/type-annotations-optional
Open

fix: Use Optional[T] for nullable type annotation defaults#325
kuishou68 wants to merge 3 commits into
OpenBMB:mainfrom
kuishou68:fix/type-annotations-optional

Conversation

@kuishou68

Copy link
Copy Markdown
Contributor

Summary

This PR fixes incorrect type annotations where bare types (int, str) are used with None as default value. Per PEP 484, these should be Optional[T] = None.

Changes

  • kv_channels: int = Nonekv_channels: Optional[int] = None (config.py)
  • out_dim: int = Noneout_dim: Optional[int] = None (local_dit.py)
  • cache_dir: str = Nonecache_dir: Optional[str] = None (core.py)
  • prompt_wav_path: str = Noneprompt_wav_path: Optional[str] = None (core.py)
  • prompt_text: str = Noneprompt_text: Optional[str] = None (core.py)
  • reference_wav_path: str = Nonereference_wav_path: Optional[str] = None (core.py)

Files Modified

  1. src/voxcpm/modules/minicpm4/config.py — add Optional import, fix kv_channels annotation
  2. src/voxcpm/modules/locdit/local_dit.py — add Optional import, fix out_dim annotation
  3. src/voxcpm/core.py — fix cache_dir, prompt_wav_path, prompt_text, reference_wav_path annotations

Closes #324

kuishou68 added 3 commits June 1, 2026 16:55
Co-authored-by: kuishou68 <54054995+kuishou68@users.noreply.github.com>
Co-authored-by: kuishou68 <54054995+kuishou68@users.noreply.github.com>
Fix cache_dir, prompt_wav_path, prompt_text, and reference_wav_path.

Co-authored-by: kuishou68 <54054995+kuishou68@users.noreply.github.com>
@a710128

a710128 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for the cleanup! The changes themselves look safe and annotation-only, and the lightweight checks passed on my side:

  • python3 -m pytest tests/test_cli.py -> passed
  • python3 -m compileall -q src/voxcpm -> passed

One thing I noticed is that the conversion is still a bit incomplete. Since the PR title is about using Optional[T] for nullable defaults, there are a few closely related cases that would be good to update as well:

  • src/voxcpm/modules/locdit/local_dit_v2.py: out_dim: int = None mirrors the updated local_dit.py implementation.
  • src/voxcpm/model/voxcpm.py and src/voxcpm/model/voxcpm2.py: config fields like kv_channels: int = None remain unchanged.
  • src/voxcpm/model/voxcpm2.py: prompt-related nullable string args such as prompt_text, prompt_wav_path, and reference_wav_path still use str = None.

Could you please include these related nullable annotations too? That would make the PR consistent and complete. Thanks!

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.

fix: Incorrect type annotations — use Optional[T] instead of T for nullable defaults

2 participants