Skip to content

fix: Add mypy easy fixes to repository.#192

Merged
bvanelli merged 5 commits into
mainfrom
mypy/easy-cases
Mar 24, 2026
Merged

fix: Add mypy easy fixes to repository.#192
bvanelli merged 5 commits into
mainfrom
mypy/easy-cases

Conversation

@bvanelli
Copy link
Copy Markdown
Owner

@bvanelli bvanelli commented Mar 23, 2026

Summary

This PR adds initial mypy type checking support and fixes the easy/straightforward type errors across the codebase. It reduces the total mypy error count from 511 errors across 14 files down to 232 errors across 3 files.

Error reduction: 279 errors fixed (54.6% reduction)

Supports #190

Mypy report comparison

Per-file error count

File main This PR Delta
actual/rules.py 218 214 -4
actual/queries.py 140 15 -125
actual/__init__.py 57 3 -54
actual/database.py 52 0 -52
actual/cli/main.py 19 0 -19
actual/budgets.py 7 0 -7
actual/schedules.py 4 0 -4
actual/api/models.py 3 0 -3
actual/protobuf_models.py 3 0 -3
actual/utils/changeset.py 2 0 -2
actual/api/__init__.py 2 0 -2
actual/cli/config.py 2 0 -2
actual/api/bank_sync.py 1 0 -1
actual/exceptions.py 1 0 -1
Total 511 232 -279

Error categories

Error type main This PR Delta
[operator] 128 156 +28
[arg-type] 91 32 -59
[union-attr] 87 14 -73
[str] 71 77 +6
[assignment] 51 6 -45
[bool] 38 0 -38
[call-overload] 10 10 0
[attr-defined] 7 5 -2
[return-value] 6 1 -5
[index] 4 4 0
[import-untyped] 3 0 -3
[call-arg] 3 0 -3
[var-annotated] 3 0 -3
[misc] 2 3 +1
[return] 2 0 -2

Note: The [operator] and [str] increases come from actual/rules.py, where stricter typing now surfaces previously hidden issues with enum comparisons. These are not regressions — they are pre-existing issues now made visible.

Remaining errors (232)

The remaining 232 errors are concentrated in 3 files:

  • actual/rules.py (214) — Mostly [operator] and [str] errors from enum/literal type comparisons in the rules engine. These require deeper refactoring of the rules type system.
  • actual/queries.py (15) — Primarily [call-overload] errors from SQLModel's Session.exec() overload resolution, which is a known upstream issue.
  • actual/__init__.py (3) — Minor type narrowing issues.

Changes made

  • Added mypy configuration to pyproject.toml with types-python-dateutil stub dependency
  • Fixed type annotations across 15 source files and 4 test files
  • Added proper Optional types, type narrowing (assert, if guards), and return type annotations
  • Fixed None-safety issues (union-attr), argument type mismatches (arg-type), and assignment incompatibilities
  • Fixed missing return statements and import stubs

🤖 This report has been generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 93.45238% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.60%. Comparing base (6410640) to head (5e85357).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
actual/__init__.py 90.81% 9 Missing ⚠️
actual/queries.py 92.30% 6 Missing ⚠️
actual/database.py 93.90% 5 Missing ⚠️
actual/exceptions.py 0.00% 1 Missing ⚠️
actual/rules.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #192      +/-   ##
==========================================
- Coverage   98.01%   97.60%   -0.42%     
==========================================
  Files          21       21              
  Lines        3131     3212      +81     
==========================================
+ Hits         3069     3135      +66     
- Misses         62       77      +15     

☔ 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.

@bvanelli bvanelli merged commit 983b463 into main Mar 24, 2026
9 checks passed
@bvanelli bvanelli deleted the mypy/easy-cases branch March 24, 2026 19:01
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.

1 participant