From b0a0af403c079ef0464d36a0d98989b6374130b2 Mon Sep 17 00:00:00 2001 From: dachengx Date: Sun, 28 Apr 2024 21:06:19 -0500 Subject: [PATCH] Record all base classes when multiple inheritance --- strax/context.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/strax/context.py b/strax/context.py index 626dcd41..0659cc3a 100644 --- a/strax/context.py +++ b/strax/context.py @@ -321,6 +321,9 @@ def register(self, plugin_class): self.register(x) return + if not issubclass(plugin_class, strax.Plugin): + raise ValueError(f"Can only register subclasses of strax.Plugin, not {plugin_class}!") + if not hasattr(plugin_class, "provides"): # No output name specified: construct one from the class name snake_name = strax.camel_to_snake(plugin_class.__name__) @@ -840,8 +843,6 @@ def __add_lineage_to_plugin(self, run_id, plugin): # drop the parents config from the lineage configs = {} - # Getting information about the parent: - parent_class = plugin.__class__.__bases__[0] # Get all parent options which are overwritten by a child: parent_options = [ option.parent_option_name @@ -861,7 +862,8 @@ def __add_lineage_to_plugin(self, run_id, plugin): configs[option_name] = v # Also adding name and version of the parent to the lineage: - configs[parent_class.__name__] = parent_class.__version__ + for parent_class in plugin.__class__.__bases__: + configs[parent_class.__name__] = parent_class.__version__ plugin.lineage = { last_provide: (plugin.__class__.__name__, plugin.version(run_id), configs)