Skip to content

vulture does not detect code usage by case clauses in pattern matching #276

@exoriente

Description

@exoriente

Hi,

I'm running into a issue with pattern matching and vulture. In my case the property of a class is only used during pattern matching. Vulture doesn't pick up on it and considers it dead code. I've whitelisted the properties for now, but it would be great if vulture could be improved to cover this new scenario.

Pseudo code example:

@dataclass
class MyClass
    my_field: MyType
    
    @property
    my_test(self) -> bool:
        return my_field == my_constant

def do_something(x: Object) -> None:
    match x:
        case MyClass(my_test=True):
            do_stuff(x)
        case MyClass(my_test=False):
            do_other_stuff(x)

In this example, vulture seems to flag my_test as dead code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions