mirror of
https://github.com/beetbox/beets.git
synced 2026-01-16 21:25:14 +01:00
Replaced filter with list comprehension.
This commit is contained in:
parent
0592b783b3
commit
f5f76f2b85
1 changed files with 18 additions and 19 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue