diff --git a/beets/plugins.py b/beets/plugins.py index b5c3d421b..0c7bae234 100644 --- a/beets/plugins.py +++ b/beets/plugins.py @@ -151,9 +151,9 @@ class BeetsPlugin(metaclass=abc.ABCMeta): list ) listeners: ClassVar[dict[EventType, list[Listener]]] = defaultdict(list) - template_funcs: ClassVar[TFuncMap[str]] = {} - template_fields: ClassVar[TFuncMap[Item]] = {} - album_template_fields: ClassVar[TFuncMap[Album]] = {} + template_funcs: ClassVar[TFuncMap[str]] | TFuncMap[str] = {} # type: ignore[valid-type] + template_fields: ClassVar[TFuncMap[Item]] | TFuncMap[Item] = {} # type: ignore[valid-type] + album_template_fields: ClassVar[TFuncMap[Album]] | TFuncMap[Album] = {} # type: ignore[valid-type] name: str config: ConfigView @@ -219,14 +219,14 @@ class BeetsPlugin(metaclass=abc.ABCMeta): self.name = name or self.__module__.split(".")[-1] self.config = beets.config[self.name] - # Set class attributes if they are not already set - # for the type of plugin. + # If the class attributes are not set, initialize as instance attributes. + # TODO: Revise with v3.0.0, see also type: ignore[valid-type] above if not self.template_funcs: - self.template_funcs = {} # type: ignore[misc] + self.template_funcs = {} if not self.template_fields: - self.template_fields = {} # type: ignore[misc] + self.template_fields = {} if not self.album_template_fields: - self.album_template_fields = {} # type: ignore[misc] + self.album_template_fields = {} self.early_import_stages = [] self.import_stages = []