Skip to content

Commit

Permalink
(3.8) Remove outdated sys.version_info checks (#375)
Browse files Browse the repository at this point in the history
Co-authored-by: Cooper Lees <me@cooperlees.com>
  • Loading branch information
FozzieHi and cooperlees authored May 9, 2023
1 parent d752c44 commit 3f16173
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
5 changes: 0 additions & 5 deletions bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,11 +1216,6 @@ def check_for_b906(self, node: ast.FunctionDef):
self.errors.append(B906(node.lineno, node.col_offset))

def check_for_b907(self, node: ast.JoinedStr): # noqa: C901
# AST structure of strings in f-strings in 3.7 is different enough this
# implementation doesn't work
if sys.version_info <= (3, 7):
return # pragma: no cover

def myunparse(node: ast.AST) -> str: # pragma: no cover
if sys.version_info >= (3, 9):
return ast.unparse(node)
Expand Down
20 changes: 7 additions & 13 deletions tests/test_bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_b006_b008(self):
B006(72, 19),
B006(76, 31),
B006(80, 25),
B006(85, 45 if sys.version_info >= (3, 8) else 46),
B006(85, 45),
B008(85, 60),
B006(89, 45),
B008(89, 63),
Expand All @@ -131,7 +131,7 @@ def test_b006_b008(self):
B008(109, 38),
B008(113, 11),
B008(113, 31),
B008(117, 29 if sys.version_info >= (3, 8) else 30),
B008(117, 29),
B008(160, 29),
B008(164, 44),
B006(170, 19),
Expand Down Expand Up @@ -294,20 +294,17 @@ def test_b019(self):
filename = Path(__file__).absolute().parent / "b019.py"
bbc = BugBearChecker(filename=str(filename))
errors = list(bbc.run())

# AST Decorator column location for callable decorators changes in 3.7
col = 5 if sys.version_info >= (3, 7) else 4
self.assertEqual(
errors,
self.errors(
B019(73, 5),
B019(77, 5),
B019(81, col),
B019(85, col),
B019(81, 5),
B019(85, 5),
B019(89, 5),
B019(93, 5),
B019(97, col),
B019(101, col),
B019(97, 5),
B019(101, 5),
),
)

Expand Down Expand Up @@ -431,7 +428,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 if sys.version_info >= (3, 8) else 30, 4, vars=("empty_5",)),
B027(31, 4, vars=("empty_5",)),
)
self.assertEqual(errors, expected)

Expand Down Expand Up @@ -505,7 +502,6 @@ def test_b908(self):
)
self.assertEqual(errors, expected)

@unittest.skipIf(sys.version_info < (3, 8), "not implemented for <3.8")
def test_b907(self):
filename = Path(__file__).absolute().parent / "b907.py"
bbc = BugBearChecker(filename=str(filename))
Expand Down Expand Up @@ -553,7 +549,6 @@ def test_b907(self):
# manual permutations to save overhead when doing >60k permutations
# see format spec at
# https://docs.python.org/3/library/string.html#format-specification-mini-language
@unittest.skipIf(sys.version_info < (3, 8), "not implemented for <3.8")
def test_b907_format_specifier_permutations(self):
visitor = BugBearVisitor(filename="", lines="")

Expand Down Expand Up @@ -631,7 +626,6 @@ def test_b902(self):
),
)

@unittest.skipIf(sys.version_info < (3, 8), "requires 3.8+")
def test_b902_py38(self):
filename = Path(__file__).absolute().parent / "b902_py38.py"
bbc = BugBearChecker(filename=str(filename))
Expand Down

0 comments on commit 3f16173

Please sign in to comment.