From f5f76f2b857b2ec37e4d495f33408966bbeb5a74 Mon Sep 17 00:00:00 2001 From: Sebastian Mohr Date: Fri, 19 Sep 2025 19:16:07 +0200 Subject: [PATCH] Replaced filter with list comprehension. --- beets/plugins.py | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/beets/plugins.py b/beets/plugins.py index 6526c65ca..7998895c6 100644 --- a/beets/plugins.py +++ b/beets/plugins.py @@ -377,26 +377,25 @@ def _get_plugin(name: str) -> BeetsPlugin | None: members = [getattr(namespace, key) for key in exports] # Determine all classes that extend `BeetsPlugin` - plugin_classes = list( - filter( - lambda obj: ( - inspect.isclass(obj) - and not isinstance( - obj, GenericAlias - ) # seems to be needed for python <= 3.9 only - and issubclass(obj, BeetsPlugin) - and obj != BeetsPlugin - and not inspect.isabstract(obj) - # Only consider this plugin's module or submodules to avoid - # conflicts when plugins import other BeetsPlugin classes - and ( - obj.__module__ == namespace.__name__ - or obj.__module__.startswith(f"{namespace.__name__}.") - ) - ), - members, + plugin_classes = [ + obj + for obj in members + if ( + inspect.isclass(obj) + and not isinstance( + obj, GenericAlias + ) # seems to be needed for python <= 3.9 only + and issubclass(obj, BeetsPlugin) + and obj != BeetsPlugin + and not inspect.isabstract(obj) + # Only consider this plugin's module or submodules to avoid + # conflicts when plugins import other BeetsPlugin classes + and ( + obj.__module__ == namespace.__name__ + or obj.__module__.startswith(f"{namespace.__name__}.") + ) ) - ) + ] if len(plugin_classes) > 1: warnings.warn(