Skip to content

Commit a7ef770

Browse files
committed
Send the pluginload event after types and queries are available
Making these types and queries available is part of fully loading the plugins, so the event should not be sent until this work is done. This allows plugins to make use of those types and queries in a pluginload listener.
1 parent f3552f0 commit a7ef770

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

beets/ui/__init__.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,6 @@ def _load_plugins(options, config):
11291129
plugin_list = config['plugins'].as_str_seq()
11301130

11311131
plugins.load_plugins(plugin_list)
1132-
plugins.send("pluginload")
11331132
return plugins
11341133

11351134

@@ -1145,16 +1144,6 @@ def _setup(options, lib=None):
11451144

11461145
plugins = _load_plugins(options, config)
11471146

1148-
# Get the default subcommands.
1149-
from beets.ui.commands import default_commands
1150-
1151-
subcommands = list(default_commands)
1152-
subcommands.extend(plugins.commands())
1153-
1154-
if lib is None:
1155-
lib = _open_library(config)
1156-
plugins.send("library_opened", lib=lib)
1157-
11581147
# Add types and queries defined by plugins.
11591148
plugin_types_album = plugins.types(library.Album)
11601149
library.Album._types.update(plugin_types_album)
@@ -1166,6 +1155,18 @@ def _setup(options, lib=None):
11661155
library.Item._queries.update(plugins.named_queries(library.Item))
11671156
library.Album._queries.update(plugins.named_queries(library.Album))
11681157

1158+
plugins.send("pluginload")
1159+
1160+
# Get the default subcommands.
1161+
from beets.ui.commands import default_commands
1162+
1163+
subcommands = list(default_commands)
1164+
subcommands.extend(plugins.commands())
1165+
1166+
if lib is None:
1167+
lib = _open_library(config)
1168+
plugins.send("library_opened", lib=lib)
1169+
11691170
return subcommands, plugins, lib
11701171

11711172

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ For plugin developers:
5656

5757
* :py:meth:`beets.library.Item.destination` now accepts a `replacements`
5858
argument to be used in favor of the default.
59+
* Send the `pluginload` event after plugin types and queries are available, not before.
5960

6061
Bug fixes:
6162

0 commit comments

Comments
 (0)