Skip to content

Commit

Permalink
fix B024 & B027 on python < 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
jakkdl committed Sep 29, 2022
1 parent 8462c1f commit b01e327
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions bugbear.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bugbear.py
Expand Up @@ -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)

Expand Down

0 comments on commit b01e327

Please sign in to comment.