Skip to content

Commit

Permalink
Record all base classes when multiple inheritance (#832)
Browse files Browse the repository at this point in the history
  • Loading branch information
dachengx authored Apr 29, 2024
1 parent 274742e commit a23fb91
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions strax/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit a23fb91

Please sign in to comment.