Skip to content

v1.6.0 — Python Quality Refactoring

Choose a tag to compare

@trek-e trek-e released this 30 Mar 23:20
· 77 commits to main since this release

What's Changed

Structural refactoring for code quality — no behavioral changes.

Highlights

  • Generic field syncer — _sync_performers, _sync_tags, _sync_collection unified into a single sync_field() function with FieldSyncSpec dataclass, eliminating ~160 lines of duplication
  • Decomposed processor.py — Extracted MetadataUpdater class (261 lines) and field_sync module (151 lines), reducing processor.py from 1293 to 854 lines
  • DRY Pydantic validators — Three near-identical sanitize validators replaced with a factory function
  • Import consolidation — Pure-function imports moved to module level; remaining lazy imports annotated with reasons
  • Test modernization — Builder factories (make_plex_item, make_config, make_job, make_stash_scene) replace rigid fixtures; parametrized field sync tests cover all three field types

Stats

Metric Before After
processor.py lines 1293 854
Test coverage ~88% 90%
Tests 1223 1212

Test count decreased by 11 (redundant tests removed, 45 new tests added for extracted modules).

New Files

  • worker/field_sync.py — Generic field sync logic
  • worker/metadata_updater.py — Metadata update orchestration
  • worker/errors.py — Base error classes (extracted to break circular import)
  • tests/factories.py — Reusable test object builders