Skip to content

Code cleanup: Ruff linting improvements - #41

Open
anthonypdawson wants to merge 6 commits into
masterfrom
chore/ruff-cleanup
Open

anthonypdawson wants to merge 6 commits into
masterfrom
chore/ruff-cleanup

Conversation

@anthonypdawson

Copy link
Copy Markdown
Owner

Summary

Massive code quality improvement reducing lint violations from 1830 to 39 (97.9% reduction).

Changes

  • Ignored intentional patterns:

    • ARG* rules (unused args required for Qt signals, abstract methods, interface compliance)
    • Test-specific tolerances (ambiguous variable names in math code, unicode in docs)
    • Non-critical datetime issues (cache timestamps don't need timezones)
  • Auto-fixed 95+ safe violations

  • Applied unsafe fixes for formatting consistency

  • Formatted all code with ruff format (44 files reformatted)

  • Manual fix: Removed unused PackageNotFoundError import in __init__.py

Remaining Work

39 edge-case violations remain for manual review:

  • 7 unused imports (need context to verify safety)
  • 5 module imports not at top (intentional lazy imports?)
  • 4 unused loop control variables
  • 4 mutable class defaults (mostly in tests)
  • 19 misc (collapsible-if, bare except, etc.)

These will be addressed in follow-up commits before enabling blocking lint enforcement.

Testing

  • Lint still advisory-only (continue-on-error: true in workflow)
  • All existing tests should pass
  • No functional changes, only style/cleanup

Next Steps

  1. Merge this PR to establish the baseline
  2. Address remaining 39 violations in follow-up
  3. Remove continue-on-error from lint.yml to make it blocking

Closes part of the technical debt from initial PR #40 setup.

Fixes metadata display for LanceDB databases with flat schemas (e.g., Contextus)
where metadata is stored as individual columns rather than nested in a 'metadata' column.

## Changes

### LanceDB Connection
- Extract metadata from PyArrow schema first (all non-reserved columns)
- Support flat schema format in get_all_items() - build metadata dicts from column values
- Detect and exclude content column from metadata to prevent duplication
- Maintain backward compatibility with nested 'metadata' column format
- Fix count detection when schema extraction succeeds but count is unavailable

### UI
- Add 600px max-width constraint to table columns to prevent excessive width
- Prevent 'document' column from appearing twice (once as content, once as metadata)

### Tests
- Add comprehensive flat schema metadata extraction tests
- Update existing tests to reflect content column exclusion from metadata
- Verify backward compatibility with nested metadata format

Closes #XX
- Enable CI test workflow on all PRs to master/main
- Add new lint workflow with ruff (check + format)
- Linting is advisory-only (won't block merges) until codebase is cleaned up
- Tests remain blocking as expected
- Update RELEASE_REASON.md to v0.8.4 (matches CHANGELOG and pyproject.toml)
- Add permissions blocks to CI workflows per GitHub security recommendation
- Added ignore rules for ARG* (unused args required for interfaces)
- Added ignore rules for test-specific patterns (E741, RUF003, DTZ005)
- Applied ruff auto-fixes (--fix + --unsafe-fixes)
- Formatted all code with ruff format
- Fixed unused import in __init__.py

Remaining 39 violations are edge cases that need manual review.
Will address in follow-up commits before enabling blocking lint.

This branch has not been deployed

No deployments
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