Skip to content

Add Ruff rules B018 and UP034 - #1243

Open
Abhayindia wants to merge 20 commits into
casact:mainfrom
Abhayindia:feature/ruff-b018-up034
Open

Add Ruff rules B018 and UP034#1243
Abhayindia wants to merge 20 commits into
casact:mainfrom
Abhayindia:feature/ruff-b018-up034

Conversation

@Abhayindia

@Abhayindia Abhayindia commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Bundles B018 and UP034 since the cleanup overlaps and you mentioned several rule issues can go in one PR.

B018 (useless-expression) turned up a real bug: MunichAdjustment.transform builds the ldf triangle but had obj._set_slicers without the call, so the returned triangle never rebuilt its .iloc/.loc/.at indexers after the shape change. The rest was test-side - a couple of dead lines, some smoke-check expressions bound to _, and the empty-triangle check in TriangleDisplay._dimensionality switched to hasattr instead of catching AttributeError on a bare self.values.

UP034 (extraneous-parentheses) was a few redundant paren pairs in clark.py, benktander.py and a couple of tests/notebooks.

Since touching a file drops its per-file-ignore protection, I cleaned each file I touched to the full ruleset and removed its entry: clark.py (also type(x) == -> isinstance and a stray assigned lambda -> def), display.py, test_bootstrap.py, test_munich.py. test_development.py, incremental.py, test_voting.py and two notebooks still trip one of the new rules but are big enough that a full cleanup belongs in its own PR, so they're grandfathered.

Related GitHub Issue(s)

Closes #1235
Closes #1236

Additional Context for Reviewers

ruff check + format with both rules is clean over the project apart from the grandfathered files. pytest passes for every touched module locally (234 tests). ruff format didn't touch any .. testcode:: block so the doctest build is unaffected.

@github-actions

github-actions Bot commented Aug 29, 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.2% of exported symbols fully typed (209 / 1377)

Known Ambiguous Unknown Total
Project (head) 209 111 1057 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: 325
  • 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 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.70%. Comparing base (5f34bcd) to head (14bbc4d).

Files with missing lines Patch % Lines
chainladder/development/clark.py 77.77% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1243      +/-   ##
==========================================
- Coverage   91.70%   91.70%   -0.01%     
==========================================
  Files          93       93              
  Lines        5435     5434       -1     
  Branches      699      700       +1     
==========================================
- Hits         4984     4983       -1     
  Misses        327      327              
  Partials      124      124              
Flag Coverage Δ
unittests 91.70% <90.90%> (-0.01%) ⬇️

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

looks good. please resolve conflict and i can approve

@Abhayindia
Abhayindia force-pushed the feature/ruff-b018-up034 branch from 6be607d to 14bbc4d Compare September 2, 2026 10:34
@Abhayindia

Copy link
Copy Markdown
Contributor Author

rebased on main - the only conflict was in pyproject.toml (main dropped the base.py per-file-ignore, this PR drops clark.py's), resolved to drop both. ruff check + format clean on the changed files.

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.

Add Ruff rule: extraneous-parentheses (UP034) Add Ruff rule: useless-expression (B018)

2 participants