Hacking: enable extensions H106, H203 and H904

[H106] Don't put vim configuration in source files.
[H203] Use assertIs(Not)None to check for None.
[H904] Delay string interpolations at logging calls.

This change makes Patrole's hacking consistent with
Tempest's [0][1].

[0] https://review.openstack.org/#/c/408211/
[1] https://review.openstack.org/#/c/408066/

Change-Id: Ia56f66b4ab7e1eea6a8bfea05bf52865be13430c
This commit is contained in:
Felipe Monteiro 2017-05-07 14:44:21 +01:00
parent 4791c4b11b
commit 4bf66a2285
4 changed files with 7 additions and 6 deletions

View File

@ -81,7 +81,7 @@ class RbacPolicyParser(object):
path = getattr(CONF.rbac, '%s_policy_file' % str(service), None)
if not path:
LOG.info("No config option found for %s,"
" using default path" % str(service))
" using default path", str(service))
path = os.path.join('/etc', service, 'policy.json')
self.path = path
self.rules = policy.Rules.load(self._get_policy_data(service),

View File

@ -104,7 +104,7 @@ def action(service, rule='', admin_only=False, expected_error_code=403,
(role, rule))
LOG.error(msg)
raise exceptions.Forbidden(
"%s exception was: %s" % (msg, e))
"%s Exception was: %s" % (msg, e))
except Exception as e:
exc_info = sys.exc_info()
error_details = exc_info[1].__str__()
@ -115,7 +115,7 @@ def action(service, rule='', admin_only=False, expected_error_code=403,
six.reraise(exc_info[0], exc_info[0](msg), exc_info[2])
else:
if not allowed:
LOG.error("Role %s was allowed to perform %s" %
LOG.error("Role %s was allowed to perform %s",
(role, rule))
raise rbac_exceptions.RbacOverPermission(
"OverPermission: Role %s was allowed to perform %s" %

View File

@ -255,7 +255,8 @@ class RBACRuleValidationTest(base.TestCase):
"sentinel.action"), e.__str__())
mock_log.error.assert_called_once_with(
"Role Member was allowed to perform sentinel.action")
'Role %s was allowed to perform %s', ('Member',
mock.sentinel.action))
@mock.patch.object(rbac_rv, 'rbac_policy_parser', autospec=True)
def test_invalid_policy_rule_throws_parsing_exception(

View File

@ -53,9 +53,9 @@ commands =
commands = oslo_debug_helper -t patrole_tempest_plugin/tests {posargs}
[flake8]
# E123, E125 skipped as they are invalid PEP-8.
enable-extensions = H106,H203,H904
show-source = True
# E123, E125 skipped as they are invalid PEP-8.
ignore = E123,E125
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build