[FEAT] Add deprecation tools - #1323
Conversation
Pyright Type CompletenessView the full Project (full
Other symbols referenced but not exported by
Symbols without documentation:
Patch (exported symbols added or changed by this PR): no exported symbol type-completeness changes detected. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1323 +/- ##
==========================================
+ Coverage 91.70% 93.91% +2.20%
==========================================
Files 96 98 +2
Lines 5464 7669 +2205
Branches 704 1223 +519
==========================================
+ Hits 5011 7202 +2191
- Misses 328 329 +1
- Partials 125 138 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
curious why you are skipping all the example testcode blocks? |
|
testcode/testoutput doesn't capture warnings - we'd have to test those using pytest |
|
|
||
| @_deprecated_rename("new_func", version="0.11.0") | ||
| def old_func(x): | ||
| return x + 1 |
There was a problem hiding this comment.
should this snippet be
@_deprecated_rename("new_func", version="0.11.0")
def old_func(x):
return new_func(x)
print(old_func(1))| def func(a, b, new_arg=None): | ||
| return a, b, new_arg | ||
|
|
||
| with warnings.catch_warnings(record=True) as caught: |
| def func(new_arg): | ||
| return new_arg | ||
|
|
||
| with warnings.catch_warnings(record=True) as caught: |
There was a problem hiding this comment.
i think this happens a couple of times to deserve a _warn_never?
|
@genedan bump |
… new_func. Add _warn_never helper func to unit tests.
|
k, it's ready. |
|
I started using the argument rename. since the work pattern is to already rename the argument before adding the decorator, the warning message actually should be stronger. will raise a PR shortly |
Summary of Changes
Needed to close #1316.
Adds three generalized deprecation tools:
This simplifies the deprecation process by allowing contributors to simply mark a feature with a decorator.
This enables a standardized way of marking features for deprecation, and enables us to run checks prior to releasing new versions that we actually deprecated the things we said we would.
Related GitHub Issue(s)
#1320
#1321
#1322
Additional Context for Reviewers
Checklist
uv run pytest) and documentation changes (uv run --directory docs jb build . --builder=custom --custom-builder=doctest)Note
Low Risk
Adds internal deprecation helpers and tests only; runtime behavior of the library is unchanged until decorators are applied to specific APIs.
Overview
Introduces three decorator factories in
chainladder/_config/deprecation.pyfor a consistent deprecation workflow:_deprecated_rename(warn when an old function name is called),_deprecated_rename_argument(map old kwargs to new names with a warning, reject both), and_deprecated_drop_argument(warn when a kwarg slated for removal is used). Each supports optional target version and warning category, usesfunctools.wraps, and emitsFutureWarningby default.The helpers are re-exported from
chainladder._configand the top-levelchainladderpackage alongside existing deprecation utilities. ARCHITECTURE.md now documentschainladder/_config/tests/. A newtest_deprecation.pysuite covers warning text, categories, argument forwarding, metadata preservation, and repeat-call behavior.No existing public APIs are wired to these decorators in this PR; this is foundational tooling for upcoming deprecations (e.g. issues #1320–#1322).
Reviewed by Cursor Bugbot for commit a4e1e32. Bugbot is set up for automated code reviews on this repo. Configure here.