Enable and resolve some PEP8 issues

* E128 continuation line under-indented for visual indent
* H501 don't use locals() for formatting strings. to also check
* H402 first line of docstring should end with punctuation
* E122 continuation line missing indentation or outdented
* E713 test for membership should be 'not in'

Change-Id: I4a30350778a4452075e468400effcbc4155d24d8
This commit is contained in:
Ekaterina Chernova 2015-02-04 13:09:16 +03:00
parent f27037cf14
commit 8a15466301
9 changed files with 45 additions and 39 deletions

View File

@ -355,7 +355,7 @@ def load_paste_app(app_name=None):
return app
except (LookupError, ImportError) as e:
msg = _("Unable to load %(app_name)s from "
"configuration file %(conf_file)s."
"\nGot: %(e)r") % locals()
"configuration file %(conf_file)s. \nGot: %(e)r",
{'conf_file': conf_file, 'app_name': app_name, 'e': e})
logger.error(msg)
raise RuntimeError(msg)

View File

@ -180,7 +180,7 @@ package_to_tag = sa.Table('package_to_tag',
sa.Column('tag_id',
sa.String(36),
sa.ForeignKey('tag.id',
ondelete="CASCADE")))
ondelete="CASCADE")))
class Instance(Base):

View File

@ -50,7 +50,7 @@ class CoreServices(object):
if env_description is None:
return None
if not 'services' in env_description:
if 'services' not in env_description:
return []
result = utils.TraverseHelper.get(path, env_description)
@ -71,7 +71,7 @@ class CoreServices(object):
env_description = get_description(environment_id, session_id)
if env_description is None:
raise exc.HTTPMethodNotAllowed
if not 'services' in env_description:
if 'services' not in env_description:
env_description['services'] = []
if path == '/services':

View File

@ -77,7 +77,7 @@ class ModelPolicyEnforcer(object):
False,
{'query': 'predeploy_errors(eid, oid, msg)',
'action_policy': 'action',
'sequence': rules_str})
'sequence': rules_str})
if validation_result["result"]:

View File

@ -52,14 +52,14 @@ class FakeLogMixin:
fixtures.FakeLogger(level=logging.DEBUG))
base_list = set([nlog.split('.')[0]
for nlog in logging.Logger.manager.loggerDict])
for base in base_list:
if base in TEST_DEFAULT_LOGLEVELS:
for base_name in base_list:
if base_name in TEST_DEFAULT_LOGLEVELS:
self.useFixture(fixtures.FakeLogger(
level=TEST_DEFAULT_LOGLEVELS[base],
name=base))
elif base != 'murano':
level=TEST_DEFAULT_LOGLEVELS[base_name],
name=base_name))
elif base_name != 'murano':
self.useFixture(fixtures.FakeLogger(
name=base))
name=base_name))
class MuranoApiTestCase(base.MuranoWithDBTestCase, FakeLogMixin):

View File

@ -63,16 +63,27 @@ class TestActionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
test_utils.save_models(e)
rpc_task = {
'tenant_id': self.tenant,
'model': {'Objects': {'applications': [], '?':
{
'_actions': {'actionsID_action': {
'name': 'Testaction', 'enabled': True}},
'id': '12345'}}, 'Attributes': {}},
'action': {
'args': '{}',
'method': 'Testaction',
'object_id': '12345',
'args': '{}'},
'object_id': '12345'
},
'tenant_id': self.tenant,
'model': {
'Attributes': {},
'Objects': {
'applications': [],
'?': {
'_actions': {
'actionsID_action': {
'enabled': True,
'name': 'Testaction'
}
},
'id': '12345'
}
}
},
'token': None,
'id': '12345'
}

View File

@ -23,7 +23,7 @@ import murano.policy.congress_rules as congress
class MockClassLoader(object):
def __init__(self, rules):
"""Create rules like this: ['child->parent', 'child->parent2']"""
"""Create rules like this: ['child->parent', 'child->parent2']."""
self._rules_dict = {}
for rule in rules:
@ -34,7 +34,7 @@ class MockClassLoader(object):
self._rules_dict[split[0]] = [split[1]]
def get_class(self, name):
if not name in self._rules_dict:
if name not in self._rules_dict:
return None
parents = []
for parent_name in self._rules_dict[name]:
@ -214,7 +214,7 @@ class TestCongressRules(unittest.TestCase):
with open(expected_rules_file) as f:
for line in f:
line = line.rstrip('\n')
if not line in rules_str:
if line not in rules_str:
s += 'Expected rule not found:\n\t' + line + '\n'
if len(s) > 0:

View File

@ -38,7 +38,7 @@ class SysLogHandlersTestCase(base.MuranoTestCase):
self.logger.binary_name = 'Foo_application'
def test_rfc_format(self):
"""Ensure syslog msg contains APP-NAME for RFC wrapped handler"""
"""Ensure syslog msg contains APP-NAME for RFC wrapped handler."""
logrecord = logging.LogRecord('name', 'WARN', '/tmp', 1,
'Message', None, None)
expected = logging.LogRecord('name', 'WARN', '/tmp', 1,
@ -47,7 +47,7 @@ class SysLogHandlersTestCase(base.MuranoTestCase):
expected.getMessage())
def test_standard_format(self):
"""Ensure syslog msg isn't modified for standard handler"""
"""Ensure syslog msg isn't modified for standard handler."""
logrecord = logging.LogRecord('name', 'WARN', '/tmp', 1,
'Message', None, None)
expected = logrecord

23
tox.ini
View File

@ -38,24 +38,19 @@ commands = flake8
commands = oslo-config-generator --config-file etc/oslo-config-generator/murano.conf
[flake8]
# E122 Continuation line missing indentation or outdented
# E128 Continuation line under-indented for visual indent
# E265 Block comment should start with '# '
# E713 Test for membership should be 'not in'
# F402 Shadowed by local variable
# H233 Python 3.x incompatible use of print operator
# H305 Imports not grouped correctly
# H307 Like imports should be grouped together
# H402 One line docstring needs punctuation.
# H233 Python 3.x incompatible use of print operator
# E265 block comment should start with '# '
# H305 imports not grouped correctly
# H307 like imports should be grouped together
# H405 Multi line docstring summary not separated with an empty line
# H501 Do not use locals() for string formatting
# H702 Argument to _ must be just a string
# H902 Use the 'not in' operator for collection membership evaluation
# H904 Wrap long lines in parentheses instead of a backslash
ignore =E122,E128,E265,E713,F402,H233,H305,H307,H402,H405,H501,H702,H902,H904
# H904 Wrap long lines in parentheses instead of a backslash
ignore = H233,H305,H307,E265,H405,H702,H904
show-source = true
builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools
[hacking]
import_exceptions = murano.openstack.common.gettextutils
import_exceptions = murano.openstack.common.gettextutils,
oslo.db.sqlalchemy.test_base