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:
@@ -355,7 +355,7 @@ def load_paste_app(app_name=None):
|
|||||||
return app
|
return app
|
||||||
except (LookupError, ImportError) as e:
|
except (LookupError, ImportError) as e:
|
||||||
msg = _("Unable to load %(app_name)s from "
|
msg = _("Unable to load %(app_name)s from "
|
||||||
"configuration file %(conf_file)s."
|
"configuration file %(conf_file)s. \nGot: %(e)r",
|
||||||
"\nGot: %(e)r") % locals()
|
{'conf_file': conf_file, 'app_name': app_name, 'e': e})
|
||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
raise RuntimeError(msg)
|
raise RuntimeError(msg)
|
||||||
|
@@ -180,7 +180,7 @@ package_to_tag = sa.Table('package_to_tag',
|
|||||||
sa.Column('tag_id',
|
sa.Column('tag_id',
|
||||||
sa.String(36),
|
sa.String(36),
|
||||||
sa.ForeignKey('tag.id',
|
sa.ForeignKey('tag.id',
|
||||||
ondelete="CASCADE")))
|
ondelete="CASCADE")))
|
||||||
|
|
||||||
|
|
||||||
class Instance(Base):
|
class Instance(Base):
|
||||||
|
@@ -50,7 +50,7 @@ class CoreServices(object):
|
|||||||
if env_description is None:
|
if env_description is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not 'services' in env_description:
|
if 'services' not in env_description:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
result = utils.TraverseHelper.get(path, env_description)
|
result = utils.TraverseHelper.get(path, env_description)
|
||||||
@@ -71,7 +71,7 @@ class CoreServices(object):
|
|||||||
env_description = get_description(environment_id, session_id)
|
env_description = get_description(environment_id, session_id)
|
||||||
if env_description is None:
|
if env_description is None:
|
||||||
raise exc.HTTPMethodNotAllowed
|
raise exc.HTTPMethodNotAllowed
|
||||||
if not 'services' in env_description:
|
if 'services' not in env_description:
|
||||||
env_description['services'] = []
|
env_description['services'] = []
|
||||||
|
|
||||||
if path == '/services':
|
if path == '/services':
|
||||||
|
@@ -77,7 +77,7 @@ class ModelPolicyEnforcer(object):
|
|||||||
False,
|
False,
|
||||||
{'query': 'predeploy_errors(eid, oid, msg)',
|
{'query': 'predeploy_errors(eid, oid, msg)',
|
||||||
'action_policy': 'action',
|
'action_policy': 'action',
|
||||||
'sequence': rules_str})
|
'sequence': rules_str})
|
||||||
|
|
||||||
if validation_result["result"]:
|
if validation_result["result"]:
|
||||||
|
|
||||||
|
@@ -52,14 +52,14 @@ class FakeLogMixin:
|
|||||||
fixtures.FakeLogger(level=logging.DEBUG))
|
fixtures.FakeLogger(level=logging.DEBUG))
|
||||||
base_list = set([nlog.split('.')[0]
|
base_list = set([nlog.split('.')[0]
|
||||||
for nlog in logging.Logger.manager.loggerDict])
|
for nlog in logging.Logger.manager.loggerDict])
|
||||||
for base in base_list:
|
for base_name in base_list:
|
||||||
if base in TEST_DEFAULT_LOGLEVELS:
|
if base_name in TEST_DEFAULT_LOGLEVELS:
|
||||||
self.useFixture(fixtures.FakeLogger(
|
self.useFixture(fixtures.FakeLogger(
|
||||||
level=TEST_DEFAULT_LOGLEVELS[base],
|
level=TEST_DEFAULT_LOGLEVELS[base_name],
|
||||||
name=base))
|
name=base_name))
|
||||||
elif base != 'murano':
|
elif base_name != 'murano':
|
||||||
self.useFixture(fixtures.FakeLogger(
|
self.useFixture(fixtures.FakeLogger(
|
||||||
name=base))
|
name=base_name))
|
||||||
|
|
||||||
|
|
||||||
class MuranoApiTestCase(base.MuranoWithDBTestCase, FakeLogMixin):
|
class MuranoApiTestCase(base.MuranoWithDBTestCase, FakeLogMixin):
|
||||||
|
@@ -63,16 +63,27 @@ class TestActionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
|
|||||||
test_utils.save_models(e)
|
test_utils.save_models(e)
|
||||||
|
|
||||||
rpc_task = {
|
rpc_task = {
|
||||||
'tenant_id': self.tenant,
|
|
||||||
'model': {'Objects': {'applications': [], '?':
|
|
||||||
{
|
|
||||||
'_actions': {'actionsID_action': {
|
|
||||||
'name': 'Testaction', 'enabled': True}},
|
|
||||||
'id': '12345'}}, 'Attributes': {}},
|
|
||||||
'action': {
|
'action': {
|
||||||
|
'args': '{}',
|
||||||
'method': 'Testaction',
|
'method': 'Testaction',
|
||||||
'object_id': '12345',
|
'object_id': '12345'
|
||||||
'args': '{}'},
|
},
|
||||||
|
'tenant_id': self.tenant,
|
||||||
|
'model': {
|
||||||
|
'Attributes': {},
|
||||||
|
'Objects': {
|
||||||
|
'applications': [],
|
||||||
|
'?': {
|
||||||
|
'_actions': {
|
||||||
|
'actionsID_action': {
|
||||||
|
'enabled': True,
|
||||||
|
'name': 'Testaction'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'id': '12345'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
'token': None,
|
'token': None,
|
||||||
'id': '12345'
|
'id': '12345'
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ import murano.policy.congress_rules as congress
|
|||||||
|
|
||||||
class MockClassLoader(object):
|
class MockClassLoader(object):
|
||||||
def __init__(self, rules):
|
def __init__(self, rules):
|
||||||
"""Create rules like this: ['child->parent', 'child->parent2']"""
|
"""Create rules like this: ['child->parent', 'child->parent2']."""
|
||||||
|
|
||||||
self._rules_dict = {}
|
self._rules_dict = {}
|
||||||
for rule in rules:
|
for rule in rules:
|
||||||
@@ -34,7 +34,7 @@ class MockClassLoader(object):
|
|||||||
self._rules_dict[split[0]] = [split[1]]
|
self._rules_dict[split[0]] = [split[1]]
|
||||||
|
|
||||||
def get_class(self, name):
|
def get_class(self, name):
|
||||||
if not name in self._rules_dict:
|
if name not in self._rules_dict:
|
||||||
return None
|
return None
|
||||||
parents = []
|
parents = []
|
||||||
for parent_name in self._rules_dict[name]:
|
for parent_name in self._rules_dict[name]:
|
||||||
@@ -214,7 +214,7 @@ class TestCongressRules(unittest.TestCase):
|
|||||||
with open(expected_rules_file) as f:
|
with open(expected_rules_file) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
line = line.rstrip('\n')
|
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'
|
s += 'Expected rule not found:\n\t' + line + '\n'
|
||||||
|
|
||||||
if len(s) > 0:
|
if len(s) > 0:
|
||||||
|
@@ -38,7 +38,7 @@ class SysLogHandlersTestCase(base.MuranoTestCase):
|
|||||||
self.logger.binary_name = 'Foo_application'
|
self.logger.binary_name = 'Foo_application'
|
||||||
|
|
||||||
def test_rfc_format(self):
|
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,
|
logrecord = logging.LogRecord('name', 'WARN', '/tmp', 1,
|
||||||
'Message', None, None)
|
'Message', None, None)
|
||||||
expected = logging.LogRecord('name', 'WARN', '/tmp', 1,
|
expected = logging.LogRecord('name', 'WARN', '/tmp', 1,
|
||||||
@@ -47,7 +47,7 @@ class SysLogHandlersTestCase(base.MuranoTestCase):
|
|||||||
expected.getMessage())
|
expected.getMessage())
|
||||||
|
|
||||||
def test_standard_format(self):
|
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,
|
logrecord = logging.LogRecord('name', 'WARN', '/tmp', 1,
|
||||||
'Message', None, None)
|
'Message', None, None)
|
||||||
expected = logrecord
|
expected = logrecord
|
||||||
|
23
tox.ini
23
tox.ini
@@ -38,24 +38,19 @@ commands = flake8
|
|||||||
commands = oslo-config-generator --config-file etc/oslo-config-generator/murano.conf
|
commands = oslo-config-generator --config-file etc/oslo-config-generator/murano.conf
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# E122 Continuation line missing indentation or outdented
|
# H233 Python 3.x incompatible use of print operator
|
||||||
# E128 Continuation line under-indented for visual indent
|
# E265 block comment should start with '# '
|
||||||
# E265 Block comment should start with '# '
|
# H305 imports not grouped correctly
|
||||||
# E713 Test for membership should be 'not in'
|
# H307 like imports should be grouped together
|
||||||
# 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.
|
|
||||||
# H405 Multi line docstring summary not separated with an empty line
|
# 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
|
# 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
|
||||||
# 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
|
ignore = H233,H305,H307,E265,H405,H702,H904
|
||||||
show-source = true
|
show-source = true
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools
|
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools
|
||||||
|
|
||||||
[hacking]
|
[hacking]
|
||||||
import_exceptions = murano.openstack.common.gettextutils
|
import_exceptions = murano.openstack.common.gettextutils,
|
||||||
|
oslo.db.sqlalchemy.test_base
|
||||||
|
Reference in New Issue
Block a user