Skip to content

B906 checks all classes, not just AST visitors #359

Open
@samueljsb

Description

@samueljsb

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions