Skip to content

Commit

Permalink
Avoid another source of deprecation warnings on py312 (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Jun 26, 2023
1 parent 2763a13 commit f820ba8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import math
import re
import sys
import warnings
from collections import namedtuple
from contextlib import suppress
from functools import lru_cache, partial
Expand Down Expand Up @@ -1182,7 +1183,12 @@ def check_for_b906(self, node: ast.FunctionDef):

# extract what's visited
class_name = node.name[len("visit_") :]
class_type = getattr(ast, class_name, None)

# silence any DeprecationWarnings
# that might come from accessing a deprecated AST node
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
class_type = getattr(ast, class_name, None)

if (
# not a valid ast subclass
Expand Down

0 comments on commit f820ba8

Please sign in to comment.