Skip to content

Commit a70f0dd

Browse files
authored
B906: Add visit_Bytes, visit_Num and visit_Str to the list of ignored visit_* functions (#338)
1 parent 51d7111 commit a70f0dd

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ MIT
312312
Change Log
313313
----------
314314

315+
Future
316+
~~~~~~~~~
317+
318+
* B906: Add ``visit_Bytes``, ``visit_Num`` and ``visit_Str`` to the list of ``visit_*``
319+
functions that are ignored by the B906 check. The ``ast.Bytes``, ``ast.Num`` and
320+
``ast.Str`` nodes are all deprecated, but may still be used by some codebases in
321+
order to maintain backwards compatibility with Python 3.7.
322+
315323
23.1.20
316324
~~~~~~~~~
317325

bugbear.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,11 @@ def check_for_b906(self, node: ast.FunctionDef):
10181018
"MatchStar",
10191019
"Nonlocal",
10201020
"TypeIgnore",
1021+
# These ast nodes are deprecated, but some codebases may still use them
1022+
# for backwards-compatibility with Python 3.7
1023+
"Bytes",
1024+
"Num",
1025+
"Str",
10211026
)
10221027
):
10231028
return

tests/b906.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,17 @@ def visit_Nonlocal():
8484

8585
def visit_TypeIgnore():
8686
...
87+
88+
89+
# These nodes are deprecated, but some codebases may still use them
90+
# for backwards-compatibility with Python 3.7
91+
def visit_Bytes():
92+
...
93+
94+
95+
def visit_Num():
96+
...
97+
98+
99+
def visit_Str():
100+
...

0 commit comments

Comments
 (0)