Skip to content

[FEAT] Add deprecation tools - #1323

Merged
genedan merged 4 commits into
mainfrom
#1318-deprecation
Sep 18, 2026
Merged

genedan merged 4 commits into
mainfrom
#1318-deprecation

Conversation

@genedan

@genedan genedan commented Sep 9, 2026

Copy link
Copy Markdown
Member

Summary of Changes

Needed to close #1316.

Adds three generalized deprecation tools:

  • Rename a function
  • Rename a function argument
  • Drop an argument

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

  • I passed tests locally for both code (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.py for 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, uses functools.wraps, and emits FutureWarning by default.

The helpers are re-exported from chainladder._config and the top-level chainladder package alongside existing deprecation utilities. ARCHITECTURE.md now documents chainladder/_config/tests/. A new test_deprecation.py suite 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.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Pyright Type Completeness

View the full pyright --verifytypes output for this commit

Project (full chainladder package, at this PR's head): 15.1% of exported symbols fully typed (208 / 1377)

Known Ambiguous Unknown Total
Project (head) 208 110 1059 1377

Other symbols referenced but not exported by chainladder: 13

Known Ambiguous Unknown Total
Other (head) 3 1 9 13

Symbols without documentation:

  • Functions without docstring: 327
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): no exported symbol type-completeness changes detected.

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.73950% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.91%. Comparing base (0d2d6f3) to head (a4e1e32).
⚠️ Report is 106 commits behind head on main.

Files with missing lines Patch % Lines
chainladder/_config/tests/test_deprecation.py 98.46% 3 Missing ⚠️
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     
Flag Coverage Δ
unittests 93.85% <98.73%> (+2.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@henrydingliu

Copy link
Copy Markdown
Member

curious why you are skipping all the example testcode blocks?

@genedan

genedan commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

testcode/testoutput doesn't capture warnings - we'd have to test those using pytest

Comment thread chainladder/_config/deprecation.py Outdated

@_deprecated_rename("new_func", version="0.11.0")
def old_func(x):
return x + 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this snippet be

@_deprecated_rename("new_func", version="0.11.0")
def old_func(x):
    return new_func(x)

print(old_func(1))

Comment thread chainladder/_config/tests/test_deprecation.py
Comment thread chainladder/_config/tests/test_deprecation.py
Comment thread chainladder/_config/tests/test_deprecation.py
def func(a, b, new_arg=None):
return a, b, new_arg

with warnings.catch_warnings(record=True) as caught:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not call _warn_once?

def func(new_arg):
return new_arg

with warnings.catch_warnings(record=True) as caught:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this happens a couple of times to deserve a _warn_never?

@henrydingliu henrydingliu self-assigned this Sep 10, 2026
@henrydingliu henrydingliu mentioned this pull request Sep 15, 2026
11 tasks
@henrydingliu

Copy link
Copy Markdown
Member

@genedan bump

@genedan

genedan commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

k, it's ready.

@genedan
genedan merged commit 05a9825 into main Sep 18, 2026
24 checks passed
@genedan
genedan deleted the #1318-deprecation branch September 18, 2026 02:22
@henrydingliu

Copy link
Copy Markdown
Member

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

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