Replace `Likelies` `AttrDict` with a frozen dataclass
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 31
Description
## Problem
PR #6681 introduces `Likelies` as the container for metadata used by `Source`. Although `Likelies` inherits from `AttrDict`, its fields are fixed by `get_most_common_tags()` and callers do not need arbitrary keys.
Using a dictionary-backed object hides the supported schema, permits unsupported attributes, and adds attribute lookup behavior that this container does not need. This was identified in [the PR review](https://github.com/beetbox/beets/pull/6681#discussion_r3610719923) and deferred to keep the refactor focused.
Note we need to consider that currently these `Likelies` within `Source` behave the same as `AlbumInfo` and `TrackInfo` (fields can be accessed as attributes and as dictionary keys), therefore we need to make sure the behaviour is consistent going forward. See `def distance` in `beets/autotag/distance.py`, for example.
## Expected behavior
`Likelies` should expose its supported metadata as explicit dataclass fields. Album and singleton `Source` construction, distance calculation, and importer behavior should remain unchanged.
## Suggested fix
- Replace the `AttrDict` subclass with a typed dataclass covering the existing fixed fields.
- Update `get_most_common_tags()` and `Source.from_item()` to construct it explicitly.
- Preserve `ImportTask.chosen_info()` returning a detached metadata dictionary.
- Add focused tests for album and singleton construction and dictionary conversion.
Contributor guide
Research direction
Start with get_most_common_tags() and Source.from_item(), then read def distance in beets/autotag/distance.py to understand current metadata access. Check ImportTask.chosen_info() and the existing tests before changing construction. Done means album and singleton Sources, distance calculation, importer behavior, and detached dictionary conversion remain consistent, with focused tests covering construction and conversion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100