Skip to content

ci: enforce ruff+black formatting, fix all 50 lint errors, add pre-commit hooks#18

Merged
DeepRatAI merged 23 commits intomainfrom
ci/enforce-lint-format
Feb 26, 2026
Merged

ci: enforce ruff+black formatting, fix all 50 lint errors, add pre-commit hooks#18
DeepRatAI merged 23 commits intomainfrom
ci/enforce-lint-format

Conversation

@DeepRatAI
Copy link
Owner

Summary

Closes #11

Enforces ruff check and black --check across the entire codebase. All 50 ruff errors fixed, all 113 files pass black formatting. CI lint job already runs without continue-on-error (was updated in earlier session).

Changes

Lint Fixes (50 errors → 0)

Rule Count Fix
F821 12 Added missing imports: logging, Specialty, ErrorCode (TYPE_CHECKING). Fixed bug: memory_serviceservice parameter
F841 10 Removed/prefixed unused variables: state, ttft_ms, start_time, html_lang, logger, span, etc.
B007 7 Prefixed unused loop variables with underscore
B905 5 Added strict=False to zip() calls
E741 4 Renamed ambiguous variable llab/lv in comprehensions
B904 3 Added from e to re-raised HTTPException
E712 2 Use is True instead of == True (1 fix, 1 noqa for SQLAlchemy)
I001 1 Auto-fixed import sorting
C401 1 Set comprehension instead of set(generator)
B027 1 Added noqa for intentional non-abstract empty method

Config Updates

  • pyproject.toml: Migrated ruff config from deprecated top-level to [tool.ruff.lint] section
  • .pre-commit-config.yaml: New file — Black, Ruff, Bandit, file hygiene hooks

Files Modified (23 total)

  • 15 source files under src/medex/
  • 5 test files
  • 1 config file (pyproject.toml)
  • 1 new config file (.pre-commit-config.yaml)
  • 1 init file (api/__init__.py — import sorting)

Bug Found & Fixed

controller.py:622 had self.memory_service = memory_service instead of self.memory_service = service — the parameter service was being ignored, using the instance attribute name as a variable reference (which would fail at runtime). This is a real bug caught by F821.

Verification

ruff check src/ tests/
# All checks passed!

black --check src/ tests/
# All done! 113 files would be left unchanged.

Pre-commit Setup

pip install pre-commit
pre-commit install
# Future commits will auto-check formatting

@DeepRatAI DeepRatAI added the enhancement New feature or request label Feb 26, 2026
@DeepRatAI DeepRatAI added this to the v0.1.1 - Patch milestone Feb 26, 2026
@DeepRatAI DeepRatAI merged commit 022c29d into main Feb 26, 2026
5 of 8 checks passed
@DeepRatAI DeepRatAI deleted the ci/enforce-lint-format branch February 26, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add code formatting CI enforcement (Ruff + Black)

1 participant