Skip to content

Replace Likelies AttrDict with a frozen dataclass #6920

Description

@snejus

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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions