Skip to content

ENH: Continue work on type hinting, add pyright to check type coverage.#735

Merged
genedan merged 8 commits intomainfrom
#486-type-hints
May 5, 2026
Merged

ENH: Continue work on type hinting, add pyright to check type coverage.#735
genedan merged 8 commits intomainfrom
#486-type-hints

Conversation

@genedan
Copy link
Copy Markdown
Collaborator

@genedan genedan commented May 3, 2026

Summary of Changes

Continues work on adding type hints. Also adds development dependency Pyright which is used to check the quality of the typing and provide a coverage report.

Fixes some formatting issues in docstring example in triangle.py.

Related GitHub Issue(s)

#486

Additional Context for Reviewers

Sets the Chainladder package in the virtual environment to editable mode via a setting in pyproject.toml. This was required for Pyright to generate the coverage report.

image

We're currently at 5.4%, so we have quite a ways to go until type completeness. We'll just keep chipping away at it.


Note

Medium Risk
Mostly typing/configuration work, but it tightens Common._validate_assumption to raise TypeError for unsupported inputs, which could surface new runtime errors in downstream code paths that previously fell through silently.

Overview
Type checking support was added and packaging/test config updated. This introduces pyrightconfig.json, adds pyright as a dev dependency (and updates uv.lock), ships a py.typed marker, and tweaks pytest discovery (testpaths). Coverage config now excludes if TYPE_CHECKING: blocks.

Core typing work continues across core and development. Several modules add from __future__ import annotations, TYPE_CHECKING imports, and richer type annotations for Development/DevelopmentBase helpers.

Behavioral tightening: Common._validate_assumption is refactored into a typed @staticmethod with explicit elif branches and now raises a clear TypeError for unsupported value types; a new unit test asserts this. Docs: multiple Triangle docstring examples are reformatted into Sphinx .. testcode::/.. testoutput:: blocks.

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

Comment thread chainladder/core/common.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

❌ Patch coverage is 89.18919% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.94%. Comparing base (5f23ed5) to head (9358edd).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
chainladder/core/common.py 81.81% 0 Missing and 2 partials ⚠️
chainladder/core/tests/test_triangle.py 80.00% 1 Missing ⚠️
chainladder/development/development.py 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #735      +/-   ##
==========================================
+ Coverage   85.25%   85.94%   +0.68%     
==========================================
  Files          85       85              
  Lines        4952     4924      -28     
  Branches      645      637       -8     
==========================================
+ Hits         4222     4232      +10     
+ Misses        521      491      -30     
+ Partials      209      201       -8     
Flag Coverage Δ
unittests 85.94% <89.18%> (+0.68%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

There are 4 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c5305b8. Configure here.

Comment thread chainladder/core/triangle.py Outdated
Comment thread pyproject.toml Outdated
Comment thread pyrightconfig.json Outdated
Comment thread chainladder/development/development.py Outdated
henrydingliu
henrydingliu previously approved these changes May 5, 2026
@genedan genedan merged commit 265e151 into main May 5, 2026
9 checks passed
@genedan genedan deleted the #486-type-hints branch May 5, 2026 15:04
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