Skip to content

[CHORE] Move options, deprecations into chainladder._config - #1276

Merged
genedan merged 7 commits into
mainfrom
#1145_config
Sep 5, 2026
Merged

[CHORE] Move options, deprecations into chainladder._config#1276
genedan merged 7 commits into
mainfrom
#1145_config

Conversation

@genedan

@genedan genedan commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary of Changes

Moves options and deprecation utilities into a new folder, _config. This is to adhere to the single-responsibility principle. i.e., each module should be responsible for one thing.

The overall package __init__.py is now only responsible for defining the public API - with the exception of the __version__ constant. I didn't have strong feelings about where to put that, and pandas just leaves it in __init__.py. I could move it too, if you want.

Refactored _dask_parallel_warned: bool = False to be a class, this allows it to better maintain state across multiple modules that use it when it's located in a deeper location than __init__.py. This pattern also matches how the Options class maintains the state of its options, to keep things consistent.

Related GitHub Issue(s)

#1145

Additional Context for Reviewers

Made some ruff fixes on existing files.

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
Mostly a module move with re-exports preserving the public API; small internal state and type-guard changes are covered by existing option/deprecation tests.

Overview
Refactors package configuration out of the top-level chainladder/__init__.py into a new chainladder/_config subpackage (options.py for Options, datetime constants, and options; deprecation.py for backend deprecation helpers and _resolve_pat). The public surface stays the same: cl.options, cl.Options, __dt64_*, and the existing private re-exports on chainladder are unchanged.

ARCHITECTURE.md documents the new _config layout. Minor implementation tweaks: one-time dask parallel deprecation state is now _dask_parallel_state.warned (replacing module-level _dask_parallel_warned), and set_option for ARRAY_BACKEND only warns on deprecated backends when the value is a str.

Tests in test_utilities.py were updated for the new state object and formatted to satisfy ruff (the file’s per-file ignore entry was removed from pyproject.toml).

Reviewed by Cursor Bugbot for commit 3f1986c. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Sep 3, 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): 14.9% of exported symbols fully typed (204 / 1368)

Known Ambiguous Unknown Total
Project (head) 204 111 1053 1368

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: 325
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): 13 no longer exported

Known Ambiguous Unknown Total
Patch 0 0 0 0
Patch symbol details
Symbol Status Change
chainladder.Options no longer exported (was ❌ unknown)
chainladder.Options.ARRAY_BACKEND no longer exported (was ✅ known)
chainladder.Options.ARRAY_PRIORITY no longer exported (was ✅ known)
chainladder.Options.AUTO_SPARSE no longer exported (was ✅ known)
chainladder.Options.ULT_VAL no longer exported (was ✅ known)
chainladder.Options.__init__ no longer exported (was ✅ known)
chainladder.Options.describe_option no longer exported (was ✅ known)
chainladder.Options.get_option no longer exported (was ❌ unknown)
chainladder.Options.reset_option no longer exported (was ✅ known)
chainladder.Options.set_option no longer exported (was ❌ unknown)
chainladder.__dt64_dtype__ no longer exported (was ✅ known)
chainladder.__dt64_unit__ no longer exported (was ✅ known)
chainladder.options no longer exported (was ❌ unknown)

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.16129% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.70%. Comparing base (5b79e32) to head (3f1986c).

Files with missing lines Patch % Lines
chainladder/_config/deprecation.py 85.36% 2 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1276      +/-   ##
==========================================
+ Coverage   91.68%   91.70%   +0.02%     
==========================================
  Files          93       96       +3     
  Lines        5447     5463      +16     
  Branches      704      704              
==========================================
+ Hits         4994     5010      +16     
  Misses        328      328              
  Partials      125      125              
Flag Coverage Δ
unittests 91.70% <95.16%> (+0.02%) ⬆️

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.

Comment thread chainladder/utils/tests/test_utilities.py
Comment thread chainladder/_config/deprecation.py
Comment thread chainladder/_config/options.py
@henrydingliu

Copy link
Copy Markdown
Member

a couple small nits. everything else looks good

@genedan
genedan merged commit acd0bdb into main Sep 5, 2026
24 checks passed
@genedan
genedan deleted the #1145_config branch September 5, 2026 10:54
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