Skip to content

fix: 2 improvements across 2 files#1016

Closed
tomaioo wants to merge 2 commits into
casact:mainfrom
tomaioo:improve/quality/bare-except-clauses-catching-all-excepti
Closed

fix: 2 improvements across 2 files#1016
tomaioo wants to merge 2 commits into
casact:mainfrom
tomaioo:improve/quality/bare-except-clauses-catching-all-excepti

Conversation

@tomaioo

@tomaioo tomaioo commented Jun 19, 2026

Copy link
Copy Markdown

Summary

fix: 2 improvements across 2 files

Problem

Severity: High | File: chainladder/utils/cupy.py:L15

Multiple files use bare except: clauses that catch all exceptions including KeyboardInterrupt and SystemExit, making debugging difficult and potentially masking serious errors. This pattern appears in fallback imports for optional dependencies (cupy, dask, rpy2).

Solution

Use except Exception: instead of bare except: to avoid catching system-exiting exceptions. Consider also logging the specific exception that occurred during import failure.

Changes

  • chainladder/utils/cupy.py (modified)
  • chainladder/utils/dask.py (modified)

Note

Low Risk
Two-line exception-type tweaks in optional dependency loaders; no change to runtime array logic or public APIs.

Overview
Replaces bare except: with except Exception: in the CuPy and Dask array backend shims (chainladder/utils/cupy.py, chainladder/utils/dask.py).

Import-time fallback behavior is unchanged: failed optional imports still fall back to NumPy and warn when the configured ARRAY_BACKEND expected that library. The change only stops those blocks from catching system-exiting exceptions such as KeyboardInterrupt and SystemExit.

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

tomaioo added 2 commits June 18, 2026 17:11
- Quality: Bare except clauses catching all exceptions silently
- Quality: Bare except clause in dask utility module

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
- Quality: Bare except clauses catching all exceptions silently
- Quality: Bare except clause in dask utility module

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@genedan

genedan commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Hi @tomaioo, welcome to chainladder. The most likely exception for these would be ImportError, can you change it to that?

@henrydingliu

Copy link
Copy Markdown
Collaborator

looks to be a bot

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.17%. Comparing base (b6e8349) to head (8d82413).

Files with missing lines Patch % Lines
chainladder/utils/dask.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1016   +/-   ##
=======================================
  Coverage   89.17%   89.17%           
=======================================
  Files          89       89           
  Lines        5165     5165           
  Branches      661      661           
=======================================
  Hits         4606     4606           
  Misses        392      392           
  Partials      167      167           
Flag Coverage Δ
unittests 89.17% <50.00%> (ø)

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.

@genedan

genedan commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Looks like it, @tomaioo, we're going to close this because our spidey senses think you're a bot. Apologies if this is not true, you can submit another PR if you're a human.

@genedan genedan closed this Jun 19, 2026
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