Skip to content

autotagging: tidy up autotag module#6687

Open
snejus wants to merge 5 commits into
masterfrom
tidy-up-autotag
Open

autotagging: tidy up autotag module#6687
snejus wants to merge 5 commits into
masterfrom
tidy-up-autotag

Conversation

@snejus
Copy link
Copy Markdown
Member

@snejus snejus commented May 30, 2026

What changed

  • Move Match, AlbumMatch, and TrackMatch from beets.autotag.hooks into beets.autotag.match.
  • Expand beets.autotag.__init__ to re-export main autotag types and functions like Distance, Info, Match, assign_items, tag_album, and tag_item.
  • Update internal code, plugins, tests, and docs to import from beets.autotag instead of reaching into deeper modules.

Architecture impact

  • beets.autotag now acts as the main public API for autotagging.
  • hooks.py stays focused on metadata/info structures.
  • match.py now owns match objects and matching behavior in one place.

High-level benefit

  • Import paths become simpler and more consistent.
  • Internal module boundaries are clearer.
  • Future refactors inside autotag should be safer because callers depend on beets.autotag, not module internals.

Copilot AI review requested due to automatic review settings May 30, 2026 12:20
@snejus snejus requested review from a team, asardaes, henry-oberholtzer and semohr as code owners May 30, 2026 12:20
@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.

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 look at PR. PR move Match, AlbumMatch, TrackMatch from beets.autotag.hooks into beets.autotag.match, and make beets.autotag package the one tidy front door for everything: Distance, Info, Match, assign_items, tag_album, tag_item, friends. All caller code, plugin code, tests, doc snippet updated to import from beets.autotag. grug like — less reach into deep module, complexity demon get smaller pantry.

Only one rock in path: test/autotag/test_hooks.py import AttrDict from beets.autotag, but beets/autotag/__init__.py never re-export AttrDict and not list in __all__. Package __getattr__ will raise AttributeError, so test collection will break.

Changes:

  • Move Match/AlbumMatch/TrackMatch (and their imports of plugins, dataclass) from hooks.py into match.py; tighten hooks.py runtime imports
  • Expand beets/autotag/__init__.py re-exports and __all__; drop the Distance deprecation redirect
  • Rewrite every internal/plugin/test/doc import to use the flat beets.autotag API

Reviewed changes

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

Show a summary per file
File Description
beets/autotag/init.py Re-export distance/hooks/match public names, drop Distance deprecation entry
beets/autotag/hooks.py Remove Match/AlbumMatch/TrackMatch and now-unused plugins, dataclass, TYPE_CHECKING imports
beets/autotag/match.py New home for Match/AlbumMatch/TrackMatch; move Proposal below them; type-only imports for Info/AlbumInfo/TrackInfo/Distance/Album/Item/JSONDict/AnyMatch/Candidates
beets/importer/tasks.py Switch to from beets.autotag import … for runtime + TYPE_CHECKING names
beets/metadata_plugins.py Import AlbumInfo/TrackInfo from beets.autotag, Item from beets.library.models
beets/test/helper.py Flat autotag imports for AlbumInfo/TrackInfo
beets/ui/commands/import_/display.py Flat autotag imports for TrackInfo and TYPE_CHECKING AlbumMatch/Match/TrackMatch
beets/ui/commands/import_/session.py Single beets.autotag import for match types + tag_album/tag_item
beetsplug/* (beatport, bench, bpsync, chroma, deezer, discogs/, lyrics, mbpseudo, mbsubmit, mbsync, musicbrainz, spotify, tidal/, titlecase) Update imports to the flat beets.autotag API
test/* (conftest.py, autotag/test_distance.py, autotag/test_hooks.py, autotag/test_match.py, plugins/test_art.py, plugins/test_chroma.py, plugins/test_mbpseudo.py, plugins/test_mbsync.py, plugins/test_missing.py, plugins/test_titlecase.py, test_importer.py, ui/commands/test_import.py) Update test imports to flat beets.autotag API; test_hooks.py also pulls in AttrDict which is not re-exported
docs/dev/plugins/autotagger.rst Fix snippet to import Item from beets.library

Comment thread test/autotag/test_hooks.py
@snejus snejus force-pushed the tidy-up-autotag branch from a2122e2 to 749f065 Compare May 30, 2026 12:30
Copy link
Copy Markdown
Contributor

@semohr semohr left a comment

Choose a reason for hiding this comment

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

Looks good to me. The commits need an addition in the git ignore revs file imo. Also maybe a change-log entry would be appropriate.

Thanks!

@snejus snejus force-pushed the tidy-up-autotag branch from f1d1187 to fd41e39 Compare June 2, 2026 00:29
Comment thread beetsplug/lyrics.py Fixed
@snejus snejus force-pushed the tidy-up-autotag branch from 5468933 to 50d8e4f Compare June 2, 2026 07:50
Comment thread beetsplug/lyrics.py Fixed
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

⚠️ Unsupported file format

Upload processing failed due to unsupported file format. Please review the parser error message:
Error parsing JUnit XML in D:/a/beets/beets/.reports/pytest.xml at 1:71175

Caused by:
RuntimeError: Error converting computed name to ValidatedString

Caused by:
    string is too long</code></pre>

For more help, visit our troubleshooting guide.

@snejus snejus force-pushed the tidy-up-autotag branch 2 times, most recently from ecf83ab to 3e67a14 Compare June 2, 2026 08:01
@snejus snejus force-pushed the tidy-up-autotag branch from 3e67a14 to 8e27f56 Compare June 2, 2026 08:16
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.

4 participants