autotagging: tidy up autotag module#6687
Conversation
|
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. |
There was a problem hiding this comment.
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 ofplugins,dataclass) fromhooks.pyintomatch.py; tightenhooks.pyruntime imports - Expand
beets/autotag/__init__.pyre-exports and__all__; drop theDistancedeprecation redirect - Rewrite every internal/plugin/test/doc import to use the flat
beets.autotagAPI
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 |
semohr
left a comment
There was a problem hiding this comment.
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!
|
ecf83ab to
3e67a14
Compare
What changed
Match,AlbumMatch, andTrackMatchfrombeets.autotag.hooksintobeets.autotag.match.beets.autotag.__init__to re-export main autotag types and functions likeDistance,Info,Match,assign_items,tag_album, andtag_item.beets.autotaginstead of reaching into deeper modules.Architecture impact
beets.autotagnow acts as the main public API for autotagging.hooks.pystays focused on metadata/info structures.match.pynow owns match objects and matching behavior in one place.High-level benefit
beets.autotag, not module internals.