Skip to content

autotagging: make Change polymorphic#6689

Open
snejus wants to merge 4 commits into
introduce-sourcefrom
refactor-change-representation
Open

autotagging: make Change polymorphic#6689
snejus wants to merge 4 commits into
introduce-sourcefrom
refactor-change-representation

Conversation

@snejus
Copy link
Copy Markdown
Member

@snejus snejus commented May 30, 2026

Fixes #6688

This change simplifies import preview rendering by routing both album and track matches through a single show_change() flow.

Architectural impact

  • Introduces a shared Change.from_match() factory that selects AlbumChange or TrackChange based on the match type.
  • Moves preview rendering behind polymorphic show() methods, so each change type owns its own display behavior.
  • Removes separate track-specific preview handling like show_item_change() and the related branching in session.py.

High-level effect

  • Centralizes change-preview logic in beets/ui/commands/import_/display.py.
  • Makes session.py simpler by using one preview entry point for both albums and tracks.
  • Reduces duplicate logic and makes future display changes easier to implement consistently.

In short: this refactor does not change the import flow itself, but it makes the change-display architecture more uniform, easier to follow, and easier to extend.

Copilot AI review requested due to automatic review settings May 30, 2026 13:52
@snejus snejus requested a review from a team as a code owner May 30, 2026 13:52
@github-actions
Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

❌ Patch coverage is 78.57143% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.60%. Comparing base (da82f8f) to head (d26e8f2).

Files with missing lines Patch % Lines
beets/ui/commands/import_/display.py 80.00% 5 Missing ⚠️
beets/ui/commands/import_/session.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           introduce-source    #6689   +/-   ##
=================================================
  Coverage             72.60%   72.60%           
=================================================
  Files                   163      163           
  Lines                 20811    20812    +1     
  Branches               3288     3287    -1     
=================================================
+ Hits                  15109    15110    +1     
  Misses                 4978     4978           
  Partials                724      724           
Files with missing lines Coverage Δ
beets/ui/commands/import_/session.py 57.91% <66.66%> (-0.38%) ⬇️
beets/ui/commands/import_/display.py 81.86% <80.00%> (+0.27%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

grug see PR make import preview use one show_change() path for album and track. This fits import UI by moving display choice into Change.from_match() and show() methods.

Changes:

  • Rename shared preview object to Change and add factory for album vs track match.
  • Move album tracklist display methods onto AlbumChange.
  • Simplify import session calls to always use show_change().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
beets/ui/commands/import_/display.py Adds polymorphic change display flow and album/track subclasses.
beets/ui/commands/import_/session.py Removes track-specific preview branch and calls shared display entry point.

Comment thread beets/ui/commands/import_/display.py
@snejus snejus force-pushed the refactor-change-representation branch from e4bac3a to d26e8f2 Compare May 30, 2026 14:01
@snejus snejus force-pushed the introduce-source branch from da82f8f to 067663c Compare June 2, 2026 00:21
@snejus snejus requested a review from asardaes as a code owner June 2, 2026 00:21
@snejus snejus force-pushed the refactor-change-representation branch from d26e8f2 to 1952f55 Compare June 2, 2026 00:21
@snejus snejus force-pushed the introduce-source branch from 067663c to ab82b5c Compare June 2, 2026 00:29
@snejus snejus force-pushed the refactor-change-representation branch from 1952f55 to 97e8a4f Compare June 2, 2026 00:29
@snejus snejus force-pushed the introduce-source branch from ab82b5c to b435443 Compare June 2, 2026 07:46
@snejus snejus force-pushed the refactor-change-representation branch from 97e8a4f to 90e087b Compare June 2, 2026 07:46
@snejus snejus force-pushed the introduce-source branch from b435443 to 054e0d6 Compare June 2, 2026 08:02
@snejus snejus force-pushed the refactor-change-representation branch from 90e087b to 3827a35 Compare June 2, 2026 08:02
@snejus snejus force-pushed the introduce-source branch from 054e0d6 to 864a80e Compare June 2, 2026 08:16
@snejus snejus force-pushed the refactor-change-representation branch from 3827a35 to d466ca8 Compare June 2, 2026 08:16
@snejus snejus force-pushed the introduce-source branch from 864a80e to d60f180 Compare June 2, 2026 14:48
@snejus snejus force-pushed the refactor-change-representation branch from d466ca8 to 8668ec6 Compare June 2, 2026 14:48
@snejus snejus force-pushed the introduce-source branch from d60f180 to 605a387 Compare June 2, 2026 15:29
@snejus snejus force-pushed the refactor-change-representation branch from 8668ec6 to 5e3860a Compare June 2, 2026 15:29
@snejus snejus force-pushed the introduce-source branch from 605a387 to 6db01e0 Compare June 3, 2026 14:42
@snejus snejus force-pushed the refactor-change-representation branch from 5e3860a to 609a54c Compare June 3, 2026 14:42
snejus added 4 commits June 3, 2026 16:16
Introduce Source class to encapsulate metadata extraction logic,
replacing scattered `get_most_common_tags` calls throughout codebase.

- Add Source class in importer.tasks with artist, name, and metadata
- Simplify `distance()` to accept Source.data instead of items list
- Update display functions to use Source objects
- Cache Source creation with @cached_property on ImportTask

This centralizes metadata handling and reduces coupling between
autotag and library modules.
- Route both album and track preview output through one show_change path
  with polymorphic Change helpers.
- Removes duplicate branching in session prompts and keeps preview
  rendering behavior centralized.
@snejus snejus force-pushed the introduce-source branch from 6db01e0 to c99d420 Compare June 3, 2026 15:16
@snejus snejus force-pushed the refactor-change-representation branch from 609a54c to e30f69a Compare June 3, 2026 15:16
@snejus snejus force-pushed the introduce-source branch from c99d420 to de7492d Compare June 3, 2026 18:21
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.

2 participants