--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityContext.py Fri Apr 02 11:59:41 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityContext.py Sat May 01 14:27:20 2021 +0200 @@ -24,7 +24,7 @@ from . import SecurityUtils -class SecurityContext(object): +class SecurityContext: """ Class implementing a context class for security related checks. """ @@ -231,7 +231,7 @@ if AstUtilities.isNumber(literal): literalValue = literal.n - elif AstUtilities.isString(literal): + elif AstUtilities.isString(literal) or AstUtilities.isBytes(literal): literalValue = literal.s elif isinstance(literal, ast.List): @@ -268,9 +268,6 @@ elif AstUtilities.isNameConstant(literal): literalValue = str(literal.value) - elif AstUtilities.isBytes(literal): - literalValue = literal.s - else: literalValue = None @@ -309,10 +306,7 @@ if not isinstance(argumentValues, list): # if passed a single value, or a tuple, convert to a list argumentValues = [argumentValues] - for val in argumentValues: - if argValue == val: - return True - return False + return any(argValue == val for val in argumentValues) else: # argument name not found, return None to allow testing for this # eventuality @@ -402,9 +396,7 @@ @return flag indicating the given module was found @rtype bool """ - if 'imports' in self.__context: - for imp in self.__context['imports']: - if module in imp: - return True - - return False + try: + return any(module in imp for imp in self.__context['imports']) + except KeyError: + return False