PyCQA / flake8-bugbear

A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

B906 checks all classes, not just AST visitors

samueljsb opened this issue · comments

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?