Lazy-load plugins when listing them

Keep plugin entrypoints from loading at module import time, but preserve the existing behavior of get_plugins() by loading entrypoints the first time plugins are listed outside tests.
This commit is contained in:
Simon Willison 2026-06-21 16:10:48 -07:00
commit af5e3e3a5b
2 changed files with 32 additions and 0 deletions

View file

@ -18,6 +18,7 @@ def ensure_plugins_loaded() -> None:
def get_plugins() -> List[Dict[str, Union[str, List[str]]]]:
ensure_plugins_loaded()
plugins: List[Dict[str, Union[str, List[str]]]] = []
plugin_to_distinfo = dict(pm.list_plugin_distinfo())
for plugin in pm.get_plugins():