Skip to content

Conversation

@twangodev
Copy link
Collaborator

@twangodev twangodev commented Dec 17, 2025

Summary by CodeRabbit

  • Chores
    • Updated project dependencies (added typing-extensions, replaced mypy with ty tooling, added ty) and added workspace source config; CI type-check step now runs ty.
  • Refactor
    • Broadened audio input handling so playback and saving accept more iterable types; adjusted type imports for clarity.
  • Tests
    • Updated unit tests to cover integrated playback behavior and tightened dependency error messaging.
  • New Features
    • Added a “Getting Started” example notebook demonstrating core SDK usage.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 17, 2025 01:10
@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Updated project dependencies and CI type checking; moved some typing imports to typing_extensions; broadened audio utilities to accept any iterable of byte chunks and adjusted tests and notebook example accordingly.

Changes

Cohort / File(s) Change Summary
Dependency & Configuration
pyproject.toml
Added typing-extensions>=4.15.0; replaced mypy in dev dependencies with fish-audio-sdk[utils]; added ty>=0.0.2; added [tool.uv.sources] with fish-audio-sdk = { workspace = true }.
Import Migration
src/fish_audio_sdk/io.py
Moved Concatenate and ParamSpec imports from typing to typing_extensions.
Audio input handling
src/fishaudio/utils/play.py, src/fishaudio/utils/save.py
Function signatures changed to accept Iterable[bytes] instead of Iterator[bytes]; runtime checks switched from isinstance(..., Iterator) to not isinstance(..., bytes) so non-bytes iterables are joined; added a type-ignore for IPython import in play.py.
CI Workflow
.github/workflows/python.yml
Replaced the mypy step with a ty check step and renamed the job from "Run mypy" to "Run ty".
Tests
tests/unit/test_utils.py
Updated tests to mock sounddevice and soundfile for integrated playback scenario; added/adjusted assertions for missing sounddevice dependency error messaging.
Examples
examples/getting_started.ipynb
Added a new getting-started notebook demonstrating SDK usage (client init, TTS, playback, saving, streaming, credits).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect play.py and save.py for edge cases (e.g., bytearray, memoryview, file-like objects) and ensure joining behavior is correct.
  • Verify typing import changes in src/fish_audio_sdk/io.py are compatible with supported Python/tooling.
  • Confirm CI change (ty check) and [tool.uv.sources] behave as intended in the workspace.
  • Ensure updated tests correctly mock modules and cover both installed and missing sounddevice scenarios.

Poem

🐇 I hopped through deps and stitched the sounds,
Little chunks joined up from leaps and bounds,
CI hums a new, precise soft tune,
Tests clap paws beneath the moon,
A rabbit smiles — changes done soon.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: replace mypy with ty' accurately reflects the main change: replacing the mypy type checker with ty across the codebase, including dependencies and CI/CD workflow.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/ty

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5240b45 and b0e094b.

📒 Files selected for processing (1)
  • examples/getting_started.ipynb (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • examples/getting_started.ipynb
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Integration Tests
  • GitHub Check: Integration Tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

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 aims to replace mypy with ty as the Python type checker. The changes add ty as a development dependency, introduce typing-extensions as a runtime dependency, and make adjustments to type-related code including import statements and type checking patterns.

  • Adds ty (v0.0.2) and typing-extensions (>=4.15.0) as dependencies
  • Updates isinstance checks from explicit Iterator type checking to negated bytes checking
  • Moves Concatenate and ParamSpec imports from typing to typing-extensions

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
uv.lock Adds ty package (v0.0.2) with platform-specific wheels, typing-extensions dependency, and self-referential dev dependency for fish-audio-sdk[utils]
pyproject.toml Adds typing-extensions to runtime dependencies, ty to dev dependencies, fish-audio-sdk[utils] to dev dependencies, and workspace source configuration
src/fishaudio/utils/save.py Changes isinstance check from isinstance(audio, Iterator) to not isinstance(audio, bytes)
src/fishaudio/utils/play.py Changes isinstance check from isinstance(audio, Iterator) to not isinstance(audio, bytes) and adds ty-specific ignore comment
src/fish_audio_sdk/io.py Moves Concatenate and ParamSpec imports from typing module to typing-extensions

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac5f010 and a7635c9.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • pyproject.toml (4 hunks)
  • src/fish_audio_sdk/io.py (1 hunks)
  • src/fishaudio/utils/play.py (1 hunks)
  • src/fishaudio/utils/save.py (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Python
src/fishaudio/utils/play.py

[error] 91-91: PortAudio library not found. Importing sounddevice raised OSError during test_play_sounddevice_mode.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Agent
🔇 Additional comments (5)
src/fish_audio_sdk/io.py (1)

14-15: LGTM! Fixes Python 3.9 compatibility.

The move of Concatenate and ParamSpec from typing to typing_extensions is correct. These types were only added to the standard typing module in Python 3.10, but the project supports Python 3.9+. The typing_extensions package provides backports for earlier Python versions.

pyproject.toml (2)

87-88: LGTM! Standard uv workspace configuration.

The [tool.uv.sources] section correctly configures the workspace mode for the uv tool, enabling workspace-based source discovery during development.


14-14: No action required. typing-extensions>=4.15.0 includes both Concatenate and ParamSpec — these features have been available since version 4.0.0, so the version constraint is compatible with the imports in src/fish_audio_sdk/io.py.

src/fishaudio/utils/play.py (1)

60-60: LGTM! Appropriate use of type checker ignore comment.

The # ty: ignore[unresolved-import] comment is appropriate for the IPython import, which may not be available in the type-checking environment. This prevents false positives when IPython is an optional dependency.

src/fishaudio/utils/save.py (1)

30-31: The behavioral change from isinstance(audio, Iterator) to if not isinstance(audio, bytes) is correct but verify all calling paths.

The change makes the code more permissive: it now attempts to join any non-bytes input rather than checking for explicit Iterator instances. This is technically sound from a duck-typing perspective, but the docstring and type annotation (Union[bytes, Iterator[bytes]]) constrain expected inputs to bytes or iterators.

All current callers (tests, examples, docstrings) pass bytes or results from client.tts.convert(), which should match the type annotation. Ensure future callers never pass unchecked iterables like lists or generators directly, as b"".join() will fail on non-bytes elements.

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/fishaudio/utils/play.py 86.11% <100.00%> (+11.11%) ⬆️
src/fishaudio/utils/save.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@twangodev twangodev merged commit 3ac2b9d into main Dec 17, 2025
20 checks passed
@twangodev twangodev deleted the feat/ty branch December 17, 2025 02:29
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.

2 participants