Skip to content

Commit

Permalink
TabRegistry: Check tabs using TabProtocol instead of attribute names.
Browse files Browse the repository at this point in the history
Only add classes following the tab protocol to the tab registry.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
  • Loading branch information
pebenito committed Nov 13, 2023
1 parent 6b85f9a commit af42f0b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions setoolsgui/widgets/tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit af42f0b

Please sign in to comment.