Skip to content

ci(#89): replace flake8 with ruff across CI, pre-commit, and dependencies#91

Merged
longieirl merged 9 commits intomainfrom
ci/89-ruff-migration
Mar 30, 2026
Merged

ci(#89): replace flake8 with ruff across CI, pre-commit, and dependencies#91
longieirl merged 9 commits intomainfrom
ci/89-ruff-migration

Conversation

@longieirl
Copy link
Copy Markdown
Owner

Pull Request

Summary

Migrates linting from flake8 to ruff (closes #89). ruff check replaces flake8 in all CI jobs and pre-commit hooks. All 390 violations resolved — 229 auto-fixed, remainder fixed manually or suppressed with documented per-site # noqa. G004 (214 logging f-string violations) deferred to issue #90.

Changes

  • packages/parser-core/pyproject.toml: add [tool.ruff] + [tool.ruff.lint] config (E, W, F, B, C901, G, PLC, PLR, T201, BLE001, UP, RUF); bump ruff to >=0.8.0,<1.0.0; remove flake8 dev dep; migrate .flake8 per-file-ignores
  • packages/parser-free/pyproject.toml: matching ruff config with T201 exemption for app.py
  • .flake8: deleted — config fully migrated to pyproject.toml
  • commands/init.py: replace 22 print() calls with _echo() helper using sys.stdout.write() (T201)
  • services/expense_analysis.py: narrow 3 bare except Exception to (ValueError, TypeError); 1 service-boundary # noqa: BLE001 with documented justification
  • 24 source files: per-site # noqa: PLC0415 for lazy/circular-dep imports
  • 20+ functions: per-site # noqa for C901/PLR complexity violations
  • .pre-commit-config.yaml: charliermarsh/ruff-pre-commit v0.0.265 -> astral-sh/ruff-pre-commit v0.8.0; hook id ruff -> ruff-check; flake8 hook removed
  • .github/workflows/ci.yml: flake8 -> ruff check src tests in both lint-core and lint-free jobs; install step updated
  • requirements/dev.txt: flake8>=6.0.0,<8.0.0 -> ruff>=0.8.0,<1.0.0
  • processor.py, app.py, pdf_table_extractor.py: restore backward-compat # noqa: F401 re-exports removed by auto-fix

Type

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Documentation
  • Performance
  • Security

Testing

  • Tests pass -- 1420 parser-core + 88 parser-free, 0 regressions
  • Manually tested -- ruff check exits 0 across all src+tests
  • make docker-integration passed locally

Checklist

  • Code follows project style
  • Self-reviewed
  • Documentation updated (if needed)
  • No new warnings

Downstream impact

  • This PR changes a public interface in bankstatements_core (exported class, function, or exception)

Notes

- Add [tool.ruff.lint] config block to parser-core with full E/W/F/B/C901/G/PLC/PLR/T201/BLE001/UP/RUF ruleset
- Add [tool.ruff.lint.per-file-ignores] for __init__.py and tests in parser-core
- Add [tool.ruff.lint] config block to parser-free with T201 per-file-ignores for app.py and PLC0415 for tests
- Bump ruff version constraint from >=0.0.265 to >=0.8.0,<1.0.0
- Remove flake8>=6.0.0,<8.0.0 from parser-core dev dependencies
- G004 added to ignore list in both configs (214 violations deferred)
- F401 per-file-ignores from .flake8 migrated to ruff config
- Run ruff --fix resolving 229 auto-fixable violations (UP037 quoted
  annotations, UP006 old typing generics, UP045 Optional[X]->X|None,
  UP035 deprecated typing imports, UP015 redundant open modes, UP024
  IOError->OSError, PLR5501 collapsible else-if, RUF021 chained ops,
  RUF100 stale noqa directives, F401/F841 in src files)
- Run ruff --unsafe-fixes --select RUF022 to sort __all__ in 3 files
- Run black and isort to restore consistent formatting
- Delete .flake8 (F401 per-file-ignores already migrated to ruff config)
…oqa; create G004 issue #90

- init.py: replace 22 print() calls with _echo() helper using sys.stdout.write()
- expense_analysis.py: narrow 3 bare except→(ValueError,TypeError); noqa BLE001 line 126 with justification
- 24 files: per-site # noqa: PLC0415 for lazy/circular-dep imports
- 20+ defs: per-site # noqa for C901/PLR0912/PLR0915/PLR0913 complexity
- 11 class attrs: # noqa: RUF012 for mutable defaults
- pyproject.toml: expanded per-file-ignores for tests; added E402 for shim
- Created GitHub issue #90 for deferred G004 violations (214 sites)
- ruff check exits 0 for all src+tests
… flake8

- Updated ruff repo URL from charliermarsh to astral-sh/ruff-pre-commit
- Bumped rev from v0.0.265 to v0.8.0
- Changed hook id from ruff to ruff-check (current canonical id)
- Removed flake8 hook block entirely
- Updated comment to reflect ruff as primary linter
- Updated ci.yml header comments: flake8 -> ruff in lint-core and lint-free
- Replaced Flake8 step with Ruff in lint-core job (ruff reads config from pyproject.toml)
- Replaced Flake8 step with Ruff in lint-free job
- Updated lint-free install step: pip install black isort ruff (was flake8)
- Replaced flake8>=6.0.0 with ruff>=0.8.0,<1.0.0 in requirements/dev.txt
- Removed .flake8 config file (fully superseded by [tool.ruff.lint] in pyproject.toml)
Auto-fix in Plan 01 removed noqa: F401 re-exports needed for test patching:
- processor.py: restore parse_totals_columns and to_float (re-exported from utils/config)
- app.py: restore get_columns_config (re-exported from column_config)

All 1420 parser-core and 88 parser-free tests now pass.
@longieirl longieirl merged commit 56d7c43 into main Mar 30, 2026
11 checks passed
@longieirl longieirl deleted the ci/89-ruff-migration branch March 30, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI-01: replace flake8 with ruff as the primary lint gate

2 participants