Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B906 checks all classes, not just AST visitors #359

Open
samueljsb opened this issue Feb 16, 2023 · 0 comments
Open

B906 checks all classes, not just AST visitors #359

samueljsb opened this issue Feb 16, 2023 · 0 comments

Comments

@samueljsb
Copy link
Contributor

samueljsb commented Feb 16, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant