diff --git a/pylint_nautobot/q_search_filter.py b/pylint_nautobot/q_search_filter.py index 6af1e8a..bdec39c 100644 --- a/pylint_nautobot/q_search_filter.py +++ b/pylint_nautobot/q_search_filter.py @@ -36,13 +36,14 @@ def __init__(self, *args, **kwargs): def visit_classdef(self, node: ClassDef): """Visit class definitions.""" - if not any(ancestor.qname() in self.meta_classes for ancestor in node.ancestors()): + if all( + ancestor.qname() not in self.meta_classes + for ancestor in node.ancestors() + ): return for child_node in node.get_children(): - if isinstance(child_node, Assign): - if any(isinstance(target, AssignName) and target.name == "q" for target in child_node.targets): - # because they can be ast Name or Attribute nodes - child_node_name = child_node.value.func.as_string().split(".")[-1] - if child_node_name != "SearchFilter": - self.add_message("nb-use-search-filter", node=child_node) + if isinstance(child_node, Assign) and any(isinstance(target, AssignName) and target.name == "q" for target in child_node.targets): + child_node_name = child_node.value.func.as_string().split(".")[-1] + if child_node_name != "SearchFilter": + self.add_message("nb-use-search-filter", node=child_node)