From a7ef7704f858bc3d00fafd30a1c3bea3c8e8fb03 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Mon, 15 Nov 2021 19:30:05 -0700 Subject: [PATCH] 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. --- beets/ui/__init__.py | 23 ++++++++++++----------- docs/changelog.rst | 1 + 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 5e0de77e2..121cb5dc0 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -1129,7 +1129,6 @@ def _load_plugins(options, config): plugin_list = config['plugins'].as_str_seq() plugins.load_plugins(plugin_list) - plugins.send("pluginload") return plugins @@ -1145,16 +1144,6 @@ def _setup(options, lib=None): plugins = _load_plugins(options, config) - # Get the default subcommands. - from beets.ui.commands import default_commands - - subcommands = list(default_commands) - subcommands.extend(plugins.commands()) - - if lib is None: - lib = _open_library(config) - plugins.send("library_opened", lib=lib) - # Add types and queries defined by plugins. plugin_types_album = plugins.types(library.Album) library.Album._types.update(plugin_types_album) @@ -1166,6 +1155,18 @@ def _setup(options, lib=None): library.Item._queries.update(plugins.named_queries(library.Item)) library.Album._queries.update(plugins.named_queries(library.Album)) + plugins.send("pluginload") + + # Get the default subcommands. + from beets.ui.commands import default_commands + + subcommands = list(default_commands) + subcommands.extend(plugins.commands()) + + if lib is None: + lib = _open_library(config) + plugins.send("library_opened", lib=lib) + return subcommands, plugins, lib diff --git a/docs/changelog.rst b/docs/changelog.rst index 552cdc31f..5369eb834 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -56,6 +56,7 @@ For plugin developers: * :py:meth:`beets.library.Item.destination` now accepts a `replacements` argument to be used in favor of the default. +* Send the `pluginload` event after plugin types and queries are available, not before. Bug fixes: