Skip to content

Commit 33e6d47

Browse files
committed
Suppress SyntaxWarning for B012 in >= 3.14
1 parent 1155216 commit 33e6d47

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/test_bugbear.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import subprocess
99
import sys
1010
import unittest
11+
import warnings
1112
from argparse import Namespace
1213
from pathlib import Path
1314

@@ -54,7 +55,12 @@ def test_eval(
5455
]
5556

5657
bbc = BugBearChecker(filename=str(path), options=options)
57-
errors = [e for e in bbc.run() if (test == "B950" or not e[2].startswith("B950"))]
58+
# Suppress SyntaxWarnings for B012 tests which intentionally contain
59+
# return/break/continue in finally blocks (SyntaxWarning in Python 3.14+)
60+
with warnings.catch_warnings():
61+
if test.startswith("B012"):
62+
warnings.filterwarnings("ignore", category=SyntaxWarning)
63+
errors = [e for e in bbc.run() if (test == "B950" or not e[2].startswith("B950"))]
5864
errors.sort()
5965
assert errors == tuple_expected
6066

0 commit comments

Comments
 (0)