From 225f4e6a8b88c77ac543a894e57cf32f204147ea Mon Sep 17 00:00:00 2001 From: kasium <15907922+kasium@users.noreply.github.com> Date: Mon, 29 Nov 2021 20:46:17 +0100 Subject: [PATCH] Remove detection of strings in B018 (#209) --- bugbear.py | 1 - tests/b018_classes.py | 3 ++- tests/b018_functions.py | 3 ++- tests/test_bugbear.py | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bugbear.py b/bugbear.py index 77b4dc6..9249550 100644 --- a/bugbear.py +++ b/bugbear.py @@ -639,7 +639,6 @@ def check_for_b018(self, node): if isinstance( subnode.value, ( - ast.Str, ast.Num, ast.Bytes, ast.NameConstant, diff --git a/tests/b018_classes.py b/tests/b018_classes.py index 12195c0..551b14e 100644 --- a/tests/b018_classes.py +++ b/tests/b018_classes.py @@ -1,6 +1,6 @@ """ Should emit: -B018 - on lines 15-26, 30, 32 +B018 - on lines 16-26, 30, 33 """ @@ -30,3 +30,4 @@ class Foo3: 123 a = 2 "str" + 1 diff --git a/tests/b018_functions.py b/tests/b018_functions.py index 9764274..f8c3f77 100644 --- a/tests/b018_functions.py +++ b/tests/b018_functions.py @@ -1,6 +1,6 @@ """ Should emit: -B018 - on lines 14-25, 29, 31 +B018 - on lines 15-25, 29, 32 """ @@ -29,3 +29,4 @@ def foo3(): 123 a = 2 "str" + 3 diff --git a/tests/test_bugbear.py b/tests/test_bugbear.py index c05b828..319a508 100644 --- a/tests/test_bugbear.py +++ b/tests/test_bugbear.py @@ -234,9 +234,9 @@ def test_b018_functions(self): bbc = BugBearChecker(filename=str(filename)) errors = list(bbc.run()) - expected = [B018(line, 4) for line in range(14, 26)] + expected = [B018(line, 4) for line in range(15, 26)] expected.append(B018(29, 4)) - expected.append(B018(31, 4)) + expected.append(B018(32, 4)) self.assertEqual(errors, self.errors(*expected)) def test_b018_classes(self): @@ -244,9 +244,9 @@ def test_b018_classes(self): bbc = BugBearChecker(filename=str(filename)) errors = list(bbc.run()) - expected = [B018(line, 4) for line in range(15, 27)] + expected = [B018(line, 4) for line in range(16, 27)] expected.append(B018(30, 4)) - expected.append(B018(32, 4)) + expected.append(B018(33, 4)) self.assertEqual(errors, self.errors(*expected)) def test_b901(self):