Skip to content

Add Ruff and pre-commit checks - #1198

Open
genedan wants to merge 11 commits into
mainfrom
#651_ruff
Open

Add Ruff and pre-commit checks#1198
genedan wants to merge 11 commits into
mainfrom
#651_ruff

Conversation

@genedan

@genedan genedan commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary of Changes

Adds Ruff and pre-commit to workflows.

Related GitHub Issue(s)

#651

Additional Context for Reviewers

Try out pre-commit and let me know what you think. Already, I'm seeing that it's a little annoying if you want to push small changes that you know will pass - for example, I removed some verbose comments that Claude left behind, but all the checks ran again prior to push, taking an extra 4 minutes for a very trivial change.

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
Tooling and lint configuration only; no runtime library behavior changes beyond removing unused test imports.

Overview
Introduces Ruff (Pyflakes/pycodestyle subset E4/E7/E9/F) as required CI and optional local gates, without forcing a repo-wide cleanup in one shot.

CI: A new Ruff workflow runs on pushes and PRs, linting only changed *.py files. It runs ruff check with per-file-ignores cleared (lint.per-file-ignores={}), so edited files must meet the full rule set even though pyproject.toml still lists grandfathered ignores for untouched legacy files.

Local: pre-commit installs pre-commit and pre-push hooks: Ruff on push (same empty per-file-ignores override) and full uv run pytest on every push.

Config: ruff and pre-commit are added to the dev optional dependencies; uv.lock is updated accordingly. One test file drops unused imports after lint touched it.

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

@github-actions

github-actions Bot commented Aug 8, 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 (197 / 1323)

Known Ambiguous Unknown Total
Project (head) 197 111 1015 1323

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: 316
  • 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 Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.53%. Comparing base (8209f46) to head (f40ee9d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1198      +/-   ##
==========================================
+ Coverage   91.25%   91.53%   +0.28%     
==========================================
  Files          91       91              
  Lines        5395     5575     +180     
  Branches      688      717      +29     
==========================================
+ Hits         4923     5103     +180     
  Misses        338      338              
  Partials      134      134              
Flag Coverage Δ
unittests 91.53% <ø> (+0.28%) ⬆️

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 .github/workflows/ruff.yml Fixed
@genedan

genedan commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

Good news - you can simply uncheck "Run Git hooks" when making a tiny non-breaking change to bypass running the whole suite locally.

For example, say you're working on an issue and get 99% of the work done. You run the pre-commit checks by default. But then you've got some minor edits (like removing a comment), which you can push immediately by unchecking "Run Git hooks" or whatever your IDE equivalent is.

Comment thread pyproject.toml
Comment thread .github/workflows/ruff.yml Outdated
Comment thread chainladder/tails/tests/test_constant.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 1 potential issue.

There are 2 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 8e94531. Configure here.

Comment thread .github/workflows/ruff.yml Outdated
@genedan

genedan commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

Running uv run ruff check by itself will yield a large number of errors ~200, scattered throughout the repository. To not clog up this PR, I've set the workflow to only check modified files. After this PR gets merged in, we can fix the files a handful at a time, and once the repo is clean, we can add back in the checks on the whole project.

@henrydingliu

Copy link
Copy Markdown
Member

Good news - you can simply uncheck "Run Git hooks" when making a tiny non-breaking change to bypass running the whole suite locally.

For example, say you're working on an issue and get 99% of the work done. You run the pre-commit checks by default. But then you've got some minor edits (like removing a comment), which you can push immediately by unchecking "Run Git hooks" or whatever your IDE equivalent is.

where is this checkbox? can you attach a screenshot

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.

3 participants