Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record all base classes when multiple inheritance #832

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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