flake8-bugbear
flake8-bugbear copied to clipboard
B906 checks all classes, not just AST visitors
I'm seeing some false-positives from B906 where we have node visitors that are not using the stdlib ast library:
import libcst
class CSTVisitor(libcst.CSTVisitor):
def visit_ClassDef(self, node):
pass
$ flake8 --select=B906 t.py
t.py:5:5: B906 `visit_` function with no further calls to a visit function, which might prevent the `ast` visitor from properly visiting all nodes. Consider adding a call to `self.generic_visit(node)`.
In this case, libcst.CSTVisitor does not have a generic_visit method (and the error message explicitly talks about ast, which is confusing).
Should this rule make sure it only applies to ast visitors rather than other classes that have a visit_ method?