Skip to content

feat(common): add deprecated decorator (#300) - #472

Open
borderlessboy wants to merge 1 commit into
python-accelerator-middle-layer:mainfrom
borderlessboy:feat/deprecated-decorator
Open

borderlessboy wants to merge 1 commit into
python-accelerator-middle-layer:mainfrom
borderlessboy:feat/deprecated-decorator

Conversation

@borderlessboy

Copy link
Copy Markdown

Issue Reference

Closes #300


What Was Changed

  • pyaml/common/deprecation.py: new deprecated(message=None) decorator. Works on functions, methods and classes. Each call or instantiation emits a DeprecationWarning naming the object and the optional message. Uses functools.wraps, so name and docstring are kept.
  • tests/common/test_deprecation.py: 6 tests (function, custom message, method, class, warning points at caller, metadata kept).

Why Was It Changed

The issue asks for a standard way to mark functions and classes as deprecated, with a warning to developers. Nothing in the codebase did this before.


Screenshots

N/A (library code, no UI change).


Checklist

  • I ran the change locally: tests for what I changed pass, and ruff check and format are clean
  • I covered every item the issue lists (decorator for functions, methods, classes; optional custom message; logs/warns on use)
  • I attached proof: test output below
  • This is my only open PR on a good first issue
  • Docs issue? N/A

Additional Context

Verification (Windows, Python 3.12.14):

  • pytest tests/common/test_deprecation.py: 6 passed.
  • Full suite pytest tests -m "not integration": 459 passed, 1 failed. The failure is tests/tuning_tools/test_tuning_orm.py::test_tuning_orm (PermissionError on a Windows temp file). It also fails on the unmodified base commit, so it predates this change.
  • ruff check and ruff format --check on the two new files: clean.

…er#300)

Add pyaml.common.deprecation.deprecated, which emits a DeprecationWarning naming the deprecated function, method or class, with an optional custom message. Works on functions, methods and classes; keeps metadata via functools.wraps.

Tests in tests/common/test_deprecation.py (6 passing). Full suite: 459 passed; test_tuning_orm fails on base too (Windows temp-file PermissionError).

This branch has not been deployed

No deployments
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.

Feature: deprecated decorator

1 participant