From af42f0bdf9db6a4cd617427930ff374d1dbf7119 Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Mon, 13 Nov 2023 15:57:11 -0500 Subject: [PATCH] TabRegistry: Check tabs using TabProtocol instead of attribute names. Only add classes following the tab protocol to the tab registry. Signed-off-by: Chris PeBenito --- setoolsgui/widgets/tab.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/setoolsgui/widgets/tab.py b/setoolsgui/widgets/tab.py index 8335bfda..9241abe2 100644 --- a/setoolsgui/widgets/tab.py +++ b/setoolsgui/widgets/tab.py @@ -22,7 +22,6 @@ # Show notes default setting (unchecked) NOTES_DEFAULT_CHECKED: typing.Final[bool] = False -TAB_REQUIRED_CLASSVARS: typing.Final[tuple[str, ...]] = ("section", "tab_title", "mlsonly") TAB_REGISTRY: typing.Final[dict[str, type["BaseAnalysisTabWidget"]]] = {} __all__ = ("AnalysisSection", "BaseAnalysisTabWidget", "TableResultTabWidget", @@ -52,16 +51,10 @@ class TabRegistry(QObjectType): def __new__(cls, *args, **kwargs): classdef = super().__new__(cls, *args, **kwargs) - clsname = args[0] - attributedict = args[2] - - # Only add concrete tabs with all required fields (skip base classes) - # to the tab registry - for k in TAB_REQUIRED_CLASSVARS: - if k not in attributedict: - return classdef - - TAB_REGISTRY[clsname] = classdef + # Only add classes following the tab protocol to the tab registry. + if isinstance(classdef, TabProtocol): + clsname = args[0] + TAB_REGISTRY[clsname] = classdef return classdef