diff --git a/bugbear.py b/bugbear.py index c5ec2e4..05dcfac 100644 --- a/bugbear.py +++ b/bugbear.py @@ -640,10 +640,15 @@ def empty_body(body) -> bool: isinstance(stmt, ast.Pass) or ( isinstance(stmt, ast.Expr) - and isinstance(stmt.value, ast.Constant) and ( - stmt.value.value is Ellipsis - or isinstance(stmt.value.value, str) + isinstance(stmt.value, (ast.Ellipsis, ast.Str)) + or ( + isinstance(stmt.value, ast.Constant) + and ( + stmt.value.value is Ellipsis + or isinstance(stmt.value.value, str) + ) + ) ) ) for stmt in body diff --git a/tests/test_bugbear.py b/tests/test_bugbear.py index e15c926..977bfe5 100644 --- a/tests/test_bugbear.py +++ b/tests/test_bugbear.py @@ -407,7 +407,7 @@ def test_b027(self): B027(16, 4, vars=("empty_2",)), B027(19, 4, vars=("empty_3",)), B027(23, 4, vars=("empty_4",)), - B027(31, 4, vars=("empty_5",)), + B027(31 if sys.version_info > (3, 7) else 30, 4, vars=("empty_5",)), ) self.assertEqual(errors, expected)