--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityUtils.py Fri Apr 02 11:59:41 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityUtils.py Sat May 01 14:27:20 2021 +0200 @@ -9,6 +9,7 @@ import ast import os +import contextlib import AstUtilities @@ -154,16 +155,14 @@ """ prefix = "" if isinstance(node, ast.Attribute): - try: + with contextlib.suppress(Exception): val = deepgetattr(node, 'value.id') - if val in aliases: - prefix = aliases[val] - else: - prefix = deepgetattr(node, 'value.id') - except Exception: # secok - # We can't get the fully qualified name for an attr, just return + prefix = ( + aliases[val] if val in aliases + else deepgetattr(node, 'value.id') + ) + # Id we can't get the fully qualified name for an attr, just return # its base name. - pass return "{0}.{1}".format(prefix, node.attr) else: @@ -195,9 +194,13 @@ @return list containing the line number range @rtype list of int """ - strip = {"body": None, "orelse": None, - "handlers": None, "finalbody": None} - for key in strip.keys(): + strip = { + "body": None, + "orelse": None, + "handlers": None, + "finalbody": None + } + for key in strip: if hasattr(node, key): strip[key] = getattr(node, key) node.key = [] @@ -209,7 +212,7 @@ lines_min = min(lines_min, n.lineno) lines_max = max(lines_max, n.lineno) - for key in strip.keys(): + for key in strip: if strip[key] is not None: node.key = strip[key]