diff --git a/bandit/core/utils.py b/bandit/core/utils.py index a7e1c2b60..46345f45d 100644 --- a/bandit/core/utils.py +++ b/bandit/core/utils.py @@ -373,8 +373,8 @@ def check_ast_node(name): def get_nosec(nosec_lines, context): - for lineno in context["linerange"]: - nosec = nosec_lines.get(lineno, None) + for lineno in [context["lineno"], *context["linerange"]]: + nosec = nosec_lines.get(lineno) if nosec is not None: return nosec return None