-
Notifications
You must be signed in to change notification settings - Fork 13
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:wait while speaking #238
Conversation
didnt realize bools were considered a type of int ``` isinstance(True, int) True isinstance(False, int) True ```
WalkthroughThe changes made to the Changes
Poem
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
didnt realize bools were considered a type of int ``` isinstance(True, int) True isinstance(False, int) True ```
closes #237 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (4)
ovos_workshop/skills/ovos.py (4)
Line range hint
1-31
: Review of import statementsWhile there are no changes in this section, it's worth noting that the imports seem comprehensive and include type hinting support. This is good for code readability and maintainability.
Consider grouping imports by standard library, third-party, and local imports for better organization. For example:
# Standard library imports import binascii import datetime import os # ... other standard library imports ... # Third-party imports from json_database import JsonStorage from lingua_franca.format import pronounce_number, join_list # ... other third-party imports ... # Local imports from ovos_workshop.decorators.compat import backwards_compat from ovos_workshop.decorators.killable import AbortEvent, killable_event # ... other local imports ...
Line range hint
32-1679
: Comprehensive OVOSSkill class implementationThe
OVOSSkill
class provides a robust foundation for skill development. It includes a wide range of methods for handling intents, events, settings, and more. The use of decorators for deprecation and backwards compatibility is commendable.Consider the following improvements:
- Break down this large class into smaller, more focused classes or modules to improve maintainability.
- Use more type hints throughout the class to enhance code readability and catch potential type-related errors early.
- Consider implementing abstract methods for key skill behaviors, which could be enforced in subclasses.
Example of using abstract methods:
from abc import ABC, abstractmethod class OVOSSkill(ABC): # ... existing code ... @abstractmethod def initialize(self): """ Initialize the skill. This method must be implemented by all skills. """ pass @abstractmethod def stop(self): """ Stop the skill's current activity. This method must be implemented by all skills. """ passThis would ensure that all skills implement these crucial methods.
Line range hint
1684-1685
: Proper handling of wait stateThis code correctly handles the case when
wait
is True, ensuring that the method waits for the speech to complete before proceeding. The use ofSessionManager
is appropriate for managing the session state.For improved readability, consider adding a brief comment explaining the purpose of this block:
if wait: # Wait for speech to complete if wait is True timeout = 15 if isinstance(wait, bool) else wait sess = SessionManager.get(m) sess.is_speaking = True SessionManager.wait_while_speaking(timeout, sess)
Line range hint
1-1685
: Overall assessment of OVOSSkill classThe changes made to the
speak
method effectively address the PR objective of handling boolean values correctly. TheOVOSSkill
class provides a comprehensive foundation for skill development with a wide range of functionalities.While the current implementation is functional, consider the following architectural improvements for future iterations:
Modularization: Break down the large
OVOSSkill
class into smaller, more focused classes or modules. This could improve maintainability and make it easier for developers to understand and extend specific functionalities.Consistent use of type hints: Implement type hints throughout the class to improve code readability and catch potential type-related errors early in development.
Abstract base class: Consider turning
OVOSSkill
into an abstract base class with some abstract methods that all skills must implement. This could enforce a more consistent structure across different skills.Documentation: While there are docstrings present, consider adding more detailed documentation for complex methods, especially those intended for use by skill developers.
These suggestions aim to improve the overall architecture and maintainability of the codebase while preserving its current functionality.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- ovos_workshop/skills/ovos.py (1 hunks)
Additional comments not posted (1)
ovos_workshop/skills/ovos.py (1)
1680-1683
: Improved handling ofwait
parameterThis change correctly addresses the issue with boolean values being treated as integers in Python. Now, if
wait
is a boolean, the timeout is set to 15 seconds, otherwise it uses the value ofwait
. This prevents potential bugs whenTrue
(which equals 1 in Python) is passed as thewait
parameter.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #238 +/- ##
==========================================
- Coverage 53.41% 49.17% -4.25%
==========================================
Files 37 37
Lines 4362 4362
==========================================
- Hits 2330 2145 -185
- Misses 2032 2217 +185
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
didnt realize bools were considered a type of int
Summary by CodeRabbit