Unless I'm misreading, it looks like code at the end of Tab.active_blocks cannot be reached. I'm not entirely sure what it's trying to do, but I thought I'd note it so you can take a look.
A style point: it is atypical in python to check is True or is False directly. Preferred is typically if item and if not item. The code below could be doing something tricky with a non-boolean result when getting display_tab, I suppose.
def active_blocks(self) -> List["Block"]:
"""Get active blocks list enabled in options."""
active_blocks = []
display_tab = self.handler.options.get(f"handlers.{self.id}", True)
if display_tab is False:
return active_blocks
elif display_tab is True:
return self.blocks.values()
# --- I believe if/elif block and returns above make this unreachable! - Tim
for block in self.blocks.values():
display_block = display_tab.get(block.id, True)
if display_block is False:
continue
active_blocks.append(block)
return active_blocks
I was reading the code to try and figure out how to configure the blocks visible on the Context tab.
Unless I'm misreading, it looks like code at the end of Tab.active_blocks cannot be reached. I'm not entirely sure what it's trying to do, but I thought I'd note it so you can take a look.
A style point: it is atypical in python to check
is Trueoris Falsedirectly. Preferred is typicallyif itemandif not item. The code below could be doing something tricky with a non-boolean result when getting display_tab, I suppose.I was reading the code to try and figure out how to configure the blocks visible on the Context tab.