Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/restore_dead_code #256

Merged
merged 1 commit into from
Sep 5, 2024
Merged

fix/restore_dead_code #256

merged 1 commit into from
Sep 5, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Sep 5, 2024

with deprecation warnings per #249 review

Summary by CodeRabbit

  • New Features

    • Introduced new access patterns for class properties, encouraging direct access over deprecated methods.
    • Added deprecation warnings for certain parameters to promote better coding practices.
  • Bug Fixes

    • Removed unimplemented test methods to streamline the testing process.
  • Documentation

    • Updated deprecation messages to guide users on transitioning to new access methods.

with deprecation warnings
@JarbasAl JarbasAl added the bug Something isn't working label Sep 5, 2024
Copy link

coderabbitai bot commented Sep 5, 2024

Walkthrough

The changes involve the deprecation of several methods in the TTS class, encouraging direct property access instead. Additionally, a parameter in the ReadWriteStream class constructor is marked as deprecated. The test suite has been streamlined by removing unimplemented test methods and adding relevant imports for TTS functionalities.

Changes

Files Change Summary
ovos_plugin_manager/templates/tts.py Deprecated methods added in TTS class: get_message, get_lang, get_gender, get_voice, and get.
ovos_plugin_manager/utils/__init__.py Added chop_samples parameter to ReadWriteStream constructor, marked as deprecated.
test/unittests/test_tts.py Removed unimplemented test methods; added imports for TTSValidator, get_voice_id, scan_voices, and get_voices.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TTS
    User->>TTS: Access properties
    TTS-->>User: Return properties directly
Loading

🐰 In the meadow, I hop with glee,
New paths ahead, so bright and free!
Methods old, now laid to rest,
Direct access, oh, what a quest!
With tests refined, we dance and play,
Hooray for changes, hip-hip-hooray! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@JarbasAl JarbasAl mentioned this pull request Sep 5, 2024
@JarbasAl JarbasAl added the documentation Improvements or additions to documentation label Sep 5, 2024
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: 4

Outside diff range, codebase verification and nitpick comments (2)
ovos_plugin_manager/templates/tts.py (2)

136-141: Deprecated Method get_message Still in Use

The get_message method, which has been deprecated, is still being used in the following locations within the ovos_plugin_manager/templates/tts.py file. These usages should be refactored to ensure the deprecation is complete:

  • Line 1: message = self.get_message(kwargs)
  • Line 2: message = self.get_message(kwargs)

Please update these references to prevent potential runtime issues.

Analysis chain

Review of Deprecated Method: get_message

The method get_message has been deprecated without a direct replacement. This approach is acceptable if the functionality is no longer needed or if it's being replaced by a more efficient mechanism elsewhere in the codebase. Ensure that all references to this method are removed or updated to prevent runtime errors.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `get_message` are removed or updated.

# Test: Search for the function usage. Expect: No occurrences of the old usage.
rg --type python -A 5 $'get_message'

Length of output: 66


Script:

#!/bin/bash
# Description: Verify all function calls to `get_message` are removed or updated.

# Test: Search for the function usage. Expect: No occurrences of the old usage.
rg -A 5 'get_message'

Length of output: 1558


155-163: Deprecated Method Usage Detected: get_voice

The method get_voice is still being used in the codebase, specifically in the following location. It should be replaced with self.voice to avoid runtime issues and align with the deprecation notice.

  • ovos_plugin_manager/templates/tts.py: Line with return self.get_lang(kwargs), self.get_voice(kwargs)
Analysis chain

Review of Deprecated Method: get_voice

The method get_voice has been deprecated with a suggestion to access self.voice directly. This is a straightforward simplification that should help reduce the complexity of the code. Confirm that all usages of get_voice are replaced with direct property access to avoid any runtime issues.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `get_voice` are updated to use `self.voice`.

# Test: Search for the function usage. Expect: Only occurrences of the new property access.
rg --type python -A 5 $'get_voice'

Length of output: 64


Script:

#!/bin/bash
# Description: Verify all function calls to `get_voice` are updated to use `self.voice`.

# Corrected Test: Search for the function usage in Python files.
rg --glob '*.py' -A 5 'get_voice'

Length of output: 5506

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2428205 and cc1db9b.

Files selected for processing (3)
  • ovos_plugin_manager/templates/tts.py (3 hunks)
  • ovos_plugin_manager/utils/init.py (2 hunks)
  • test/unittests/test_tts.py (3 hunks)
Additional context used
Ruff
test/unittests/test_tts.py

122-122: ovos_plugin_manager.templates.tts.TTSValidator imported but unused

Remove unused import: ovos_plugin_manager.templates.tts.TTSValidator

(F401)


179-179: ovos_plugin_manager.tts.get_voice_id imported but unused

Remove unused import: ovos_plugin_manager.tts.get_voice_id

(F401)


183-183: ovos_plugin_manager.tts.scan_voices imported but unused

Remove unused import: ovos_plugin_manager.tts.scan_voices

(F401)


187-187: ovos_plugin_manager.tts.get_voices imported but unused

Remove unused import: ovos_plugin_manager.tts.get_voices

(F401)

Additional comments not posted (4)
ovos_plugin_manager/utils/__init__.py (1)

201-203: Approve the addition of the deprecated parameter.

The addition of the chop_samples parameter, marked as deprecated, is handled correctly with a deprecation warning. This maintains backward compatibility while discouraging its use in new code. However, it would be beneficial to document this deprecation more clearly in the class docstring to ensure that it is visible to developers who might not look at the constructor's implementation directly.

ovos_plugin_manager/templates/tts.py (3)

146-153: Review of Deprecated Method: get_gender

The method get_gender has been deprecated with a suggestion to access self.voice and self.lang directly. This change is aimed at simplifying property access within the class. Verify that the transition to the new access pattern does not break existing functionality, especially where gender-specific logic might be applied.


142-145: Review of Deprecated Method: get_lang

The method get_lang has been deprecated with a suggestion to access self.lang directly. This change simplifies the code and reduces unnecessary method calls. Ensure that all instances where get_lang was used are updated to directly access the self.lang property.

Verification successful

Verification Successful: Deprecated Method get_lang

The method get_lang is not used elsewhere in the codebase, confirming that all instances have been updated to directly access self.lang as suggested. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `get_lang` are updated to use `self.lang`.

# Test: Search for the function usage. Expect: Only occurrences of the new property access.
rg --type python -A 5 $'get_lang'

Length of output: 63


Script:

#!/bin/bash
# Description: Verify all function calls to `get_lang` are updated to use `self.lang`.

# Test: Search for the function usage. Expect: Only occurrences of the new property access.
rg --type py -A 5 'get_lang'

Length of output: 26111


165-168: Review of Deprecated Method: get

The method get has been deprecated with a suggestion to access self.voice and self.lang directly. This method previously returned a tuple, so ensure that the refactoring does not affect the expected data structure in calling code. Update all relevant parts of the codebase to align with this new access pattern.

Verification successful

Verification of Deprecated Method: get

The get method in ovos_plugin_manager/templates/tts.py is not being used elsewhere in the codebase, or its usage has already been refactored to align with the new access pattern of using self.voice and self.lang directly. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `get` are updated to use `self.voice` and `self.lang`.

# Test: Search for the function usage. Expect: Only occurrences of the new property access.
rg --type python -A 5 $'get'

Length of output: 58


Script:

#!/bin/bash
# Description: Verify all function calls to `get` are updated to use `self.voice` and `self.lang`.

# Test: Search for the function usage. Expect: Only occurrences of the new property access.
rg --type py -A 5 $'get'

Length of output: 332342

# TODO

def test_scan_voices(self):
pass
from ovos_plugin_manager.tts import scan_voices
Copy link

Choose a reason for hiding this comment

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

Remove unused import: scan_voices

The import from ovos_plugin_manager.tts import scan_voices is unused in the current context. This aligns with the static analysis tool's suggestion to remove it to clean up the codebase.

Apply this diff to remove the unused import:

- from ovos_plugin_manager.tts import scan_voices
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from ovos_plugin_manager.tts import scan_voices
Tools
Ruff

183-183: ovos_plugin_manager.tts.scan_voices imported but unused

Remove unused import: ovos_plugin_manager.tts.scan_voices

(F401)

# TODO

def test_get_voices(self):
pass
from ovos_plugin_manager.tts import get_voices
Copy link

Choose a reason for hiding this comment

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

Remove unused import: get_voices

The import from ovos_plugin_manager.tts import get_voices is unused in the current context. This aligns with the static analysis tool's suggestion to remove it to clean up the codebase.

Apply this diff to remove the unused import:

- from ovos_plugin_manager.tts import get_voices
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from ovos_plugin_manager.tts import get_voices
Tools
Ruff

187-187: ovos_plugin_manager.tts.get_voices imported but unused

Remove unused import: ovos_plugin_manager.tts.get_voices

(F401)


def test_remote_tt(self):
pass
from ovos_plugin_manager.templates.tts import TTSValidator
Copy link

Choose a reason for hiding this comment

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

Remove unused import: TTSValidator

The import from ovos_plugin_manager.templates.tts import TTSValidator is unused in the current context. This aligns with the static analysis tool's suggestion to remove it to clean up the codebase.

Apply this diff to remove the unused import:

- from ovos_plugin_manager.templates.tts import TTSValidator
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from ovos_plugin_manager.templates.tts import TTSValidator
Tools
Ruff

122-122: ovos_plugin_manager.templates.tts.TTSValidator imported but unused

Remove unused import: ovos_plugin_manager.templates.tts.TTSValidator

(F401)

@@ -193,15 +176,15 @@
self.CONFIG_SECTION, None)

def test_get_voice_id(self):
pass
from ovos_plugin_manager.tts import get_voice_id
Copy link

Choose a reason for hiding this comment

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

Remove unused import: get_voice_id

The import from ovos_plugin_manager.tts import get_voice_id is unused in the current context. This aligns with the static analysis tool's suggestion to remove it to clean up the codebase.

Apply this diff to remove the unused import:

- from ovos_plugin_manager.tts import get_voice_id
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from ovos_plugin_manager.tts import get_voice_id
Tools
Ruff

179-179: ovos_plugin_manager.tts.get_voice_id imported but unused

Remove unused import: ovos_plugin_manager.tts.get_voice_id

(F401)

@JarbasAl JarbasAl merged commit b3aad67 into dev Sep 5, 2024
8 checks passed
@JarbasAl JarbasAl deleted the fix/restore_dead_code branch September 5, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant