Skip to content

Commit c8c8a55

Browse files
authored
Lower version guard in check_ast_node to Python 3.12 (#1355)
The version guard for deprecated AST node types (Num, Str, Bytes, Ellipsis, NameConstant) currently activates only on Python >= 3.14, where these types are removed. However, these types emit DeprecationWarning on Python 3.12 and 3.13 when accessed via getattr. Lower the guard from (3, 14) to (3, 12) to avoid triggering DeprecationWarning on Python 3.12-3.13. The early return behavior is identical: the node name is known-valid and is returned directly, skipping the unnecessary getattr call.
1 parent 8f2f928 commit c8c8a55

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

bandit/core/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ def parse_ini_file(f_loc):
370370
def check_ast_node(name):
371371
"Check if the given name is that of a valid AST node."
372372
try:
373-
# These ast Node types don't exist in Python 3.14, but plugins may
374-
# still check on them.
375-
if sys.version_info >= (3, 14) and name in (
373+
# These ast Node types were deprecated in Python 3.12 and removed
374+
# in Python 3.14, but plugins may still check on them.
375+
if sys.version_info >= (3, 12) and name in (
376376
"Num",
377377
"Str",
378378
"Ellipsis",

0 commit comments

Comments
 (0)