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

chore: add warnings #321

Merged
merged 2 commits into from
Jan 4, 2025
Merged

chore: add warnings #321

merged 2 commits into from
Jan 4, 2025

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Jan 4, 2025

make IDEs signal deprecated code instead of relying on runtime logs only

Summary by CodeRabbit

Release Notes

  • Deprecation Warnings

    • Added deprecation warnings across multiple utility modules
    • Notified users about recommended import paths and alternative functions
    • Marked several system and utility functions as deprecated
  • Maintenance

    • Updated import statements to include warnings module
    • Improved code documentation and user guidance
    • Prepared codebase for future refactoring and module reorganization

These changes help developers transition to newer, recommended methods and import paths in the OVOS utilities library.

make IDEs signal deprecated code instead of relying on runtime logs only
Copy link
Contributor

coderabbitai bot commented Jan 4, 2025

Warning

Rate limit exceeded

@JarbasAl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between eb13223 and cef7c30.

📒 Files selected for processing (3)
  • .github/workflows/license_tests.yml (1 hunks)
  • .github/workflows/publish_stable.yml (1 hunks)
  • .github/workflows/release_workflow.yml (1 hunks)

Walkthrough

This pull request introduces a comprehensive deprecation warning strategy across multiple modules in the ovos_utils package. The changes involve adding warnings module imports and implementing deprecation warnings for various functions and classes. The primary goal is to notify users about deprecated functionality, guiding them towards newer import paths or alternative methods, while maintaining the existing code's core functionality.

Changes

File Changes
ovos_utils/__init__.py Added deprecation warning for get_handler_name()
ovos_utils/bracket_expansion.py Added deprecation warnings for multiple functions and class constructors
ovos_utils/fakebus.py Added deprecation warning for Message class instantiation
ovos_utils/messagebus.py Added module-level deprecation warning
ovos_utils/network_utils.py Added deprecation warning for is_connected() and fixed DNS configuration retrieval
ovos_utils/ocp.py Added deprecation warning for available_extractors()
ovos_utils/signal.py Added module-level and function-level deprecation warnings
ovos_utils/system.py Added deprecation warnings for system utility functions

Poem

🐰 Hop, hop, warning's here to say
Deprecated paths will fade away
Code evolves with gentle care
New routes bloom everywhere
Old ways whisper their goodbye 🔔


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
ovos_utils/signal.py (1)

5-13: Minor formatting nitpick in the warning message.

There's a stray backtick in "ovos_utils.signal module has been deprecated without replacement\"`. Removing it will make this message cleaner. Everything else looks good for indicating a total module deprecation.

-warnings.warn(
-    "ovos_utils.signal module has been deprecated without replacement`",
-    DeprecationWarning,
-    stacklevel=2,
-)
+warnings.warn(
+    "ovos_utils.signal module has been deprecated without replacement",
+    DeprecationWarning,
+    stacklevel=2,
+)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 122f269 and eb13223.

📒 Files selected for processing (8)
  • ovos_utils/__init__.py (2 hunks)
  • ovos_utils/bracket_expansion.py (8 hunks)
  • ovos_utils/fakebus.py (2 hunks)
  • ovos_utils/messagebus.py (1 hunks)
  • ovos_utils/network_utils.py (2 hunks)
  • ovos_utils/ocp.py (2 hunks)
  • ovos_utils/signal.py (1 hunks)
  • ovos_utils/system.py (7 hunks)
🔇 Additional comments (22)
ovos_utils/messagebus.py (1)

7-14: Good addition of a direct deprecation warning.

You have successfully introduced a DeprecationWarning in addition to the existing log_deprecation call. This dual approach provides broader coverage, ensuring that both logs and IDEs highlight the deprecated status.

ovos_utils/network_utils.py (1)

6-6: Consistent deprecation strategy.

Importing warnings at line 6 and adding a direct warnings.warn call for the is_connected function aligns with the rest of the PR changes. This ensures IDEs and tooling can easily identify its deprecated status.

Also applies to: 134-138

ovos_utils/__init__.py (1)

18-18: Deprecation warning complements log_deprecation.

Importing warnings and emitting a DeprecationWarning for get_handler_name mirrors the approach in other modules. This will better surface the deprecation in IDEs and user environments.

Also applies to: 155-159

ovos_utils/bracket_expansion.py (8)

4-4: No issues with warnings import.
This import is necessary to raise deprecation warnings and is consistent with Python best practices.


95-99: Good use of warnings.warn with DeprecationWarning.
The stack level is set to 2, ensuring the warning points to the caller's frame. This helps developers locate where the deprecated function is being invoked.


112-116: Deprecation added consistently.
Same approach is repeated with appropriate stack level in expand_options. This is clear and consistent with the rest of the code.


134-138: Constructor deprecation warning is clear.
Notifies callers that they should use expand_template instead. The message is straightforward and helps nudge users toward the new implementation.


169-173: Deprecation in Word constructor is consistent.
This maintains consistency across constructors by providing the same warning message as other classes.


195-199: Consistent approach for Sentence constructor.
The repeated pattern of warnings.warn usage is appropriate for large-scale deprecation.


230-234: Consistent deprecation message for Options.
Clear, concise, and includes the replacement guidance.


258-262: Deprecation in SentenceTreeParser.__init__.
All references now consistently point to expand_template.

ovos_utils/fakebus.py (2)

4-4: No issues with warnings import.
This is required to emit deprecation warnings for the deprecated Message class.


336-340: Deprecation warning for Message class.
Clear indication to import from ovos-bus-client directly. The log_deprecation call further reinforces the timeline for removal.

ovos_utils/system.py (7)

7-7: Importing warnings is consistent with the new deprecation approach.
No issues; ensures all system-manipulation functions can emit warnings properly.


43-47: Deprecation warning in ntp_sync.
It’s clear that ovos-PHAL-plugin-system is now responsible. Stack level is suitable to guide developers to call sites.


58-62: Deprecated system_shutdown.
The warning message clearly indicates the recommended alternative.


75-79: Deprecated system_reboot.
Similar pattern used for consistent user notifications.


93-97: SSH enable function deprecation is correct.
The approach matches the other system utilities, ensuring a uniform transition path.


107-111: SSH disable function deprecation is correct.
Matches the standard approach with the recommended alternative.


121-125: Deprecation of restart_mycroft_service.
Warnings are consistent, pointing to ovos-PHAL-plugin-system as the replacement.

ovos_utils/ocp.py (2)

6-6: Implementation of the warnings import.
Maintains consistency in approach across the modules.


136-140: Deprecated available_extractors function.
The message clarifies the new import path, and stacklevel=2 properly references the caller.

@JarbasAl JarbasAl merged commit 28407fb into dev Jan 4, 2025
6 of 9 checks passed
@JarbasAl JarbasAl deleted the warnings branch January 4, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant