-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Summary
The CI runs mypy with strict = true and currently reports 63 errors across 12 source files. These are pre-existing type annotation issues — the Type Check job is set to continue-on-error: true so it doesn't block merging, but we should resolve them.
Error Breakdown by Category
no-any-return (10 errors)
Functions with return type annotations that return numpy/pandas values mypy can't verify.
| File | Lines |
|---|---|
models/ols.py |
74, 88, 110 |
models/ar.py |
102, 112 |
models/adl.py |
119, 129 |
results/base.py |
143 |
tests/bai_perron.py |
452, 459, 632 |
visualization/params.py |
145 |
Fix: Add explicit casts or adjust return type annotations.
arg-type — numpy dtype mismatches (17 errors)
Numpy signedinteger vs float64 dtype mismatches when appending to typed lists, plus ArrayLike | None vs ArrayLike issues.
| File | Lines |
|---|---|
models/ar.py |
450, 455, 461, 610 |
models/adl.py |
668, 674, 680, 790, 1032 |
rolling/ar.py |
281, 286, 546, 551 |
rolling/adl.py |
400, 406, 412, 443, 739, 745, 751, 782 |
tests/bai_perron.py |
361 |
visualization/breaks.py |
280 |
Fix: Use broader NDArray[np.floating[Any]] type annotations for lists, or cast arrays.
assignment — Figure type narrowing (6 errors)
ax.get_figure() returns Figure | SubFigure | None, but variables are typed as Figure.
| File | Lines |
|---|---|
visualization/breaks.py |
132, 254 |
visualization/diagnostics.py |
267, 391 |
visualization/params.py |
568 |
Fix: Use assert isinstance(fig, Figure) or handle the None/SubFigure cases.
unused-ignore (5 errors)
Stale # type: ignore comments that no longer match the actual error codes.
| File | Lines |
|---|---|
visualization/breaks.py |
132, 254 |
visualization/diagnostics.py |
267, 391, 506 |
Fix: Remove or update the # type: ignore comments with correct error codes.
attr-defined (2 errors)
RegressionResultsBase has no attribute sigma.
| File | Lines |
|---|---|
visualization/diagnostics.py |
381, 627 |
Fix: Add sigma to RegressionResultsBase or narrow the type to a subclass that has it.
return-value (3 errors)
Incompatible return types (e.g., returning None where ndarray expected, complex vs floating array).
| File | Lines |
|---|---|
models/ols.py |
495 |
models/ar.py |
78 |
models/adl.py |
95 |
Fix: Adjust return type annotations or add runtime checks.
union-attr (1 error)
Accessing .get_figure() on Axes | Sequence[Axes].
| File | Line |
|---|---|
visualization/params.py |
568 |
Fix: Narrow the type before calling .get_figure().
call-overload (1 error)
pd.DataFrame constructor type mismatch with dict of ndarrays.
| File | Line |
|---|---|
results/base.py |
259 |
Fix: Adjust the dict value type or add a cast.
Files Affected
src/regimes/models/ols.py(5 errors)src/regimes/models/ar.py(6 errors)src/regimes/models/adl.py(7 errors)src/regimes/rolling/ar.py(4 errors)src/regimes/rolling/adl.py(8 errors)src/regimes/tests/bai_perron.py(6 errors)src/regimes/results/base.py(3 errors)src/regimes/visualization/breaks.py(5 errors)src/regimes/visualization/diagnostics.py(7 errors)src/regimes/visualization/params.py(3 errors)
Suggested Approach
- Fix
unused-ignorecomments first (quick wins, reduces noise) - Fix
assignment/union-attrwith type narrowing (assert isinstance(...)) - Fix
no-any-returnwith explicit casts - Fix
arg-typedtype mismatches by broadening list type annotations - Fix
attr-definedby addingsigmato the base class or narrowing types - Fix
return-valueissues with corrected annotations
CI Context
The Type Check job in CI uses continue-on-error: true so these errors are visible but non-blocking. Once resolved, we can remove continue-on-error to make mypy a hard gate.