Skip to content

Don't try to initialize ABCs that inherit from BeetsPlugin or MetadataSourcePlugin #6093

@amogus07

Description

@amogus07

Problem

Running this command in verbose (-vv) mode:

$ beet -vv --plugins=vocadb version

Led to this problem:

user configuration: /home/konstantink/.config/beets/config.yaml
data directory: /home/konstantink/.config/beets
plugin paths: ['/home/konstantink/dev/src/beetsplug/more', '/home/konstantink/dev/src/whatlastgenre/plugin/beets/beetsplug', '/home/konstantink/dev/src/beets-fetchartist/beetsplug', '/home/konstantink/dev/src/beets-stylize/src/beetsplug']
Loading plugins: vocadb
** error loading plugin vocadb
Traceback (most recent call last):
  File "/home/konstantink/.local/share/uv/tools/beets/lib/python3.13/site-packages/beets/plugins.py", line 448, in _get_plugin
    return obj()
  File "/home/konstantink/.local/share/uv/tools/beets/lib/python3.13/site-packages/beetsplug/vocadb/abc.py", line 155, in __init__
    user_agent=USER_AGENT, base_url=self.api_url, logger=self._log
                                    ^^^^^^^^^^^^
AttributeError: 'PluginABC' object has no attribute 'api_url'
Sending event: pluginload
library database: /home/konstantink/.config/beets/library.db
library directory: /home/konstantink/Music
Sending event: library_opened
beets version 0.0.0
Python version 3.13.5
no plugins loaded
Sending event: cli_exit

Here's a link to a plugin that triggers the bug: https://github.com/prTopi/beets-vocadb/tree/demo

The bug is that beets tries to instantiate an ABC exposed by a module in a package under beetsplug because it inherits from beetsplug. Even though it's is only triggered by specific plugins, I still think it should be fixed within beets. In the latest commit, you can see my current workaround being reverted for demonstration purposes. I don't think it should be necessary, beets shouldn't be trying to initialize ABCs. Another solution could be restricting the location of plugin classes, only loading plugin exposed by the module or package directly under beetsplug and ignoring modules or subpackages within packages. Even better would be a combination of both.

Update:

Apparently, beets does check for abstractness, but classes without abstractmethods aren't considered abstract in Python.

Setup

  • OS: Fedora
  • Python version: 3.13
  • beets version: 2.5.0
  • Turning off plugins made problem go away (yes/no): yesn't (no more error but still unintended behavior within beets)

My configuration (output of beet config) is:

plugins:
- vocadb

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions