From 3a05843193c47f96acfbb334bb273a195de9411c Mon Sep 17 00:00:00 2001 From: Miro HronĨok Date: Apr 03 2019 11:26:06 +0000 Subject: Instead of bending linters to allow eval, stop using eval --- diff --git a/plugins/shell_api.py b/plugins/shell_api.py index 83f0cb2..f22ea7c 100644 --- a/plugins/shell_api.py +++ b/plugins/shell_api.py @@ -20,7 +20,7 @@ Plugin module acting as an interface between, simple, shell-based plugins and the regular python plugins. """ -import logging # pylint: disable=W0611 +import logging import os import os.path import re @@ -473,8 +473,7 @@ class ShellCheck(GenericCheck): for line in f.readlines(): try: tag, msg = line.split(":") - # pylint: disable=eval-used - level = eval("logging." + tag.upper()) + level = getattr(logging, tag.upper()) except (ValueError, AttributeError): self.log.error("Malformed plugin log: " + line) self.log.log(level, msg) diff --git a/src/FedoraReview/settings.py b/src/FedoraReview/settings.py index 3a889eb..ee84bc9 100644 --- a/src/FedoraReview/settings.py +++ b/src/FedoraReview/settings.py @@ -462,9 +462,9 @@ class _Settings(object): # pylint: disable=R0902 if not lvl: if "REVIEW_LOGLEVEL" in os.environ: try: - # pylint: disable=eval-used - lvl = eval("logging." + os.environ["REVIEW_LOGLEVEL"].upper()) - except (ValueError, SyntaxError): + lvl = os.environ["REVIEW_LOGLEVEL"].upper() + lvl = getattr(logging, lvl) + except AttributeError: msg = "Cannot set loglevel from REVIEW_LOGLEVEL" lvl = logging.INFO else: