B906: Add visit_Bytes, visit_Num and visit_Str to the list of ignored visit_* functions#338
Conversation
…gnored `visit_*` functions
cooperlees
left a comment
There was a problem hiding this comment.
Thanks! Can't hurt to exempt these for triggering since we still support 3.7. Just so I understand correctly we can deprecate once we're >= 3.8 right?
Strictly speaking, "we promise our plugin will work when run on Python 3.7" and "we promise that our plugin will not emit false positives when checking other code that supports being run on Python 3.7" are two different things. However, I think it's fine to drop support for other codebases supporting 3.7 at the same time as you yourself drop support for 3.7 :) That's obviously your decision to make, though! |
Cool. I feel if people choose to stay on old versions of python, they can stay on old versions of libraries + tools too ... |
|
Thanks folks! |
Hi, thanks for flake8-bugbear! I'm a maintainer of the flake8-pyi plugin for flake8, and I'd love to switch on B906 for our codebase, as I think it's a great idea for a flake8-bugbear check. Unfortunately, however, there's still a false-positive if I switch B906 on over at flake8-pyi, even with the latest release (which includes #335).
The false positive is emitted due to the fact that we have a
visit_Strmethod in ourast.NodeVisitorsubclass.ast.Strhas been deprecated since 3.8, but it's necessary for us to define avisit_Strmethod nonetheless in order to maintain backwards compatibility with Python 3.7.ast.Strnodes have a non-empty_fieldsattribute, but they can't contain any ast subnodes that could be visited, much the same asast.alias,ast.Constant, or any of the other nodes special-cased. The same applies for two other deprecated nodes:ast.Numandast.Bytes. This PR fixes the false positive on flake8-pyi's codebase by addingast.Str,ast.Numandast.Bytesto the list of AST nodes special-cased by B906.