Skip to content

Commit 225f4e6

Browse files
authored
Remove detection of strings in B018 (#209)
1 parent 9e311d5 commit 225f4e6

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

bugbear.py

-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,6 @@ def check_for_b018(self, node):
639639
if isinstance(
640640
subnode.value,
641641
(
642-
ast.Str,
643642
ast.Num,
644643
ast.Bytes,
645644
ast.NameConstant,

tests/b018_classes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Should emit:
3-
B018 - on lines 15-26, 30, 32
3+
B018 - on lines 16-26, 30, 33
44
"""
55

66

@@ -30,3 +30,4 @@ class Foo3:
3030
123
3131
a = 2
3232
"str"
33+
1

tests/b018_functions.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Should emit:
3-
B018 - on lines 14-25, 29, 31
3+
B018 - on lines 15-25, 29, 32
44
"""
55

66

@@ -29,3 +29,4 @@ def foo3():
2929
123
3030
a = 2
3131
"str"
32+
3

tests/test_bugbear.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,19 @@ def test_b018_functions(self):
234234
bbc = BugBearChecker(filename=str(filename))
235235
errors = list(bbc.run())
236236

237-
expected = [B018(line, 4) for line in range(14, 26)]
237+
expected = [B018(line, 4) for line in range(15, 26)]
238238
expected.append(B018(29, 4))
239-
expected.append(B018(31, 4))
239+
expected.append(B018(32, 4))
240240
self.assertEqual(errors, self.errors(*expected))
241241

242242
def test_b018_classes(self):
243243
filename = Path(__file__).absolute().parent / "b018_classes.py"
244244
bbc = BugBearChecker(filename=str(filename))
245245
errors = list(bbc.run())
246246

247-
expected = [B018(line, 4) for line in range(15, 27)]
247+
expected = [B018(line, 4) for line in range(16, 27)]
248248
expected.append(B018(30, 4))
249-
expected.append(B018(32, 4))
249+
expected.append(B018(33, 4))
250250
self.assertEqual(errors, self.errors(*expected))
251251

252252
def test_b901(self):

0 commit comments

Comments
 (0)