fix(oocana): add warnings.warn for deprecated APIs by leavesster · Pull Request #464 · oomol/oocana-python · GitHub
Skip to content

fix(oocana): add warnings.warn for deprecated APIs#464

Open
leavesster wants to merge 1 commit into
mainfrom
fix/deprecated-api-decorators
Open

fix(oocana): add warnings.warn for deprecated APIs#464
leavesster wants to merge 1 commit into
mainfrom
fix/deprecated-api-decorators

Conversation

@leavesster

Copy link
Copy Markdown
Contributor

Summary

  • Add warnings.warn() with DeprecationWarning for deprecated APIs
  • Affected methods: pkg_dir property, send_error() method

Problem

Deprecated APIs had docstring comments but no runtime warnings:

@property
def pkg_dir(self) -> str:
    """Deprecated, use pkg_data_dir instead."""
    return self.__pkg_data_dir

Users wouldn't know they're using deprecated APIs until reading docs.

Solution

Add proper deprecation warnings:

import warnings

@property
def pkg_dir(self) -> str:
    """Deprecated, use pkg_data_dir instead."""
    warnings.warn(
        "pkg_dir is deprecated, use pkg_data_dir instead",
        DeprecationWarning,
        stacklevel=2
    )
    return self.__pkg_data_dir

Test Plan

  • All existing tests pass
  • Using deprecated APIs now triggers visible warnings

Use warnings.warn with DeprecationWarning for deprecated methods:
- pkg_dir property: deprecated in favor of pkg_data_dir
- send_error method: deprecated in favor of error()

This allows users to catch deprecation warnings and migrate their code.
Copilot AI review requested due to automatic review settings January 31, 2026 09:28
@coderabbitai

coderabbitai Bot commented Jan 31, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds runtime deprecation warnings using Python's warnings.warn() for two deprecated APIs in the Context class that previously only had docstring notices. This ensures users are actively notified when using deprecated functionality.

Changes:

  • Added warnings module import
  • Added warnings.warn() calls with DeprecationWarning for pkg_dir property and send_error() method
  • Updated docstrings to use proper Sphinx deprecation directive format

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

@leavesster leavesster changed the title fix: add warnings.warn for deprecated APIs fix(oocana): add warnings.warn for deprecated APIs Jan 31, 2026
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