Skip to content

Possible unreachable code #65

@tpow

Description

@tpow

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions