Enable Bad String Formatting Linting
Flake8 currently ignores: H501: Do not use locals() or self.__dict__ for formatting strings Enable it to follow openstack's style guidelines: "[H501] Do not use locals() or self.__dict__ for formatting strings, it is not clear as using explicit dictionaries and can hide errors during refactoring" Change-Id: I21a956b8b52ce54045e8c91562ba9b1de3c36c02 Story: 2004515 Task: 28571 Signed-off-by: Eric Barrett <eric.barrett@windriver.com>
This commit is contained in:
parent
a3538d7377
commit
9ef596a7d9
|
@ -63,9 +63,8 @@ import six
|
|||
|
||||
from six.moves.urllib.parse import urlencode
|
||||
from six.moves.urllib.request import urlopen
|
||||
from sysinv.openstack.common.gettextutils import _
|
||||
from sysinv.openstack.common import jsonutils
|
||||
from sysinv.openstack.common import log as logging
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -391,7 +390,7 @@ def _parse_check(rule):
|
|||
try:
|
||||
kind, match = rule.split(':', 1)
|
||||
except Exception:
|
||||
LOG.exception(_("Failed to understand rule %(rule)s") % locals())
|
||||
LOG.exception("Failed to understand rule %(rule)s" % {'rule': rule})
|
||||
# If the rule is invalid, we'll fail closed
|
||||
return FalseCheck()
|
||||
|
||||
|
@ -401,7 +400,7 @@ def _parse_check(rule):
|
|||
elif None in _checks:
|
||||
return _checks[None](kind, match)
|
||||
else:
|
||||
LOG.error(_("No handler for matches of kind %s") % kind)
|
||||
LOG.error("No handler for matches of kind %s" % kind)
|
||||
return FalseCheck()
|
||||
|
||||
|
||||
|
@ -675,7 +674,7 @@ def _parse_text_rule(rule):
|
|||
return state.result
|
||||
except ValueError:
|
||||
# Couldn't parse the rule
|
||||
LOG.exception(_("Failed to understand rule %(rule)r") % locals())
|
||||
LOG.exception("Failed to understand rule %(rule)r" % {'rule': rule})
|
||||
|
||||
# Fail closed
|
||||
return FalseCheck()
|
||||
|
|
|
@ -28,7 +28,8 @@ class DictKeysMismatch(object):
|
|||
|
||||
def describe(self):
|
||||
return ('Keys in d1 and not d2: %(d1only)s.'
|
||||
' Keys in d2 and not d1: %(d2only)s' % self.__dict__)
|
||||
' Keys in d2 and not d1: %(d2only)s' % {'d1only': self.d1only,
|
||||
'd2only': self.d2only})
|
||||
|
||||
def get_details(self):
|
||||
return {}
|
||||
|
@ -42,7 +43,9 @@ class DictMismatch(object):
|
|||
|
||||
def describe(self):
|
||||
return ("Dictionaries do not match at %(key)s."
|
||||
" d1: %(d1_value)s d2: %(d2_value)s" % self.__dict__)
|
||||
" d1: %(d1_value)s d2: %(d2_value)s"
|
||||
% {'key': self.key, 'd1_value': self.d1_value,
|
||||
'd2_value': self.d2_value})
|
||||
|
||||
def get_details(self):
|
||||
return {}
|
||||
|
|
|
@ -76,11 +76,10 @@ commands =
|
|||
# H403 multi line docstrings should end on a new line
|
||||
# H404 multi line docstring should start without a leading new line
|
||||
# H405 multi line docstring summary not separated with an empty line
|
||||
# H501 Do not use self.__dict__ for string formatting
|
||||
# H701 Empty localization string
|
||||
# H702 Formatting operation should be outside of localization method call
|
||||
# H703 Multiple positional placeholders
|
||||
ignore = E126,E127,E128,E226,E402,E501,H101,H102,H104,H105,H236,H237,H238,H306,H401,H403,H404,H405,H501,H701,H702,H703
|
||||
ignore = E126,E127,E128,E226,E402,E501,H101,H102,H104,H105,H236,H237,H238,H306,H401,H403,H404,H405,H701,H702,H703
|
||||
exclude = build,dist,tools
|
||||
|
||||
[testenv:flake8]
|
||||
|
|
Loading…
Reference in New Issue