File tree Expand file tree Collapse file tree 2 files changed +120
-101
lines changed Expand file tree Collapse file tree 2 files changed +120
-101
lines changed Original file line number Diff line number Diff line change 1818
1919from copy import deepcopy
2020from dataclasses import dataclass
21+ from functools import cached_property
2122from typing import TYPE_CHECKING , Any , TypeVar
2223
2324from typing_extensions import Self
2425
26+ from beets .util import cached_classproperty
27+
2528if TYPE_CHECKING :
2629 from beets .library import Item
2730
@@ -55,6 +58,10 @@ def __hash__(self) -> int: # type: ignore[override]
5558class Info (AttrDict [Any ]):
5659 """Container for metadata about a musical entity."""
5760
61+ @cached_property
62+ def name (self ) -> str :
63+ raise NotImplementedError
64+
5865 def __init__ (
5966 self ,
6067 album : str | None = None ,
@@ -96,6 +103,10 @@ class AlbumInfo(Info):
96103 user items, and later to drive tagging decisions once selected.
97104 """
98105
106+ @cached_property
107+ def name (self ) -> str :
108+ return self .album or ""
109+
99110 def __init__ (
100111 self ,
101112 tracks : list [TrackInfo ],
@@ -168,6 +179,10 @@ class TrackInfo(Info):
168179 stand alone for singleton matching.
169180 """
170181
182+ @cached_property
183+ def name (self ) -> str :
184+ return self .title or ""
185+
171186 def __init__ (
172187 self ,
173188 * ,
@@ -220,6 +235,10 @@ class Match:
220235 distance : Distance
221236 info : Info
222237
238+ @cached_classproperty
239+ def type (cls ) -> str :
240+ return cls .__name__ .removesuffix ("Match" ) # type: ignore[attr-defined]
241+
223242
224243@dataclass
225244class AlbumMatch (Match ):
You can’t perform that action at this time.
0 commit comments