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

Possible unreachable code #65

Open
tpow opened this issue Mar 30, 2023 · 0 comments
Open

Possible unreachable code #65

tpow opened this issue Mar 30, 2023 · 0 comments

Comments

@tpow
Copy link

tpow commented Mar 30, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant