Enable PEP8 checks for E111, E241, E261, E401, E502, E713, E721

* E111 indentation is not a multiple of four
* E241 multiple spaces after ','
* E261 at least two spaces before inline comment
* E401 multiple imports on one line
* E502 the backslash is redundant between brackets
* E713 test for membership should be 'not in'
* E721 do not compare types, use 'isinstance()'

Change-Id: I7315dac1734e6adc4ecf2cc2f0cc45d5d6d8b411
This commit is contained in:
Christian Berendt 2015-01-16 15:52:35 +01:00
parent 713b745e0e
commit 1e93a38908
5 changed files with 19 additions and 18 deletions

View File

@ -249,7 +249,7 @@ class Drone(object):
Registers an observer. Given object should be subclass of class Registers an observer. Given object should be subclass of class
DroneObserver. DroneObserver.
""" """
for attr in ('applying', 'checking', 'finished'): for attr in ('applying', 'checking', 'finished'):
if not hasattr(observer, attr): if not hasattr(observer, attr):
raise ValueError('Observer object should be a subclass ' raise ValueError('Observer object should be a subclass '
'of class DroneObserver.') 'of class DroneObserver.')

View File

@ -101,7 +101,7 @@ def process_password(param, param_name, config=None):
else: else:
param = uuid.uuid4().hex[:16] param = uuid.uuid4().hex[:16]
process_password.pw_dict[unconfirmed_param] = param process_password.pw_dict[unconfirmed_param] = param
elif not param_name in process_password.pw_dict: elif param_name not in process_password.pw_dict:
param = uuid.uuid4().hex[:16] param = uuid.uuid4().hex[:16]
process_password.pw_dict[param_name] = param process_password.pw_dict[param_name] = param
else: else:

View File

@ -129,7 +129,8 @@ def _getInputFromUser(param):
del commandLineValues[param.CONF_NAME] del commandLineValues[param.CONF_NAME]
loop = True loop = True
except KeyboardInterrupt: except KeyboardInterrupt:
print "" # add the new line so messages wont be displayed in the same line as the question # add the new line so messages wont be displayed in the same line as the question
print ""
raise raise
except: except:
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
@ -222,21 +223,21 @@ def mask(input):
If it finds, it replaces them with '********' If it finds, it replaces them with '********'
""" """
output = copy.deepcopy(input) output = copy.deepcopy(input)
if type(input) == types.DictType: if isinstance(input, types.DictType):
for key in input: for key in input:
if type(input[key]) == types.StringType: if isinstance(input[key], types.StringType):
output[key] = utils.mask_string(input[key], output[key] = utils.mask_string(input[key],
masked_value_set) masked_value_set)
if type(input) == types.ListType: if isinstance(input, types.ListType):
for item in input: for item in input:
org = item org = item
orgIndex = input.index(org) orgIndex = input.index(org)
if type(item) == types.StringType: if isinstance(item, types.StringType):
item = utils.mask_string(item, masked_value_set) item = utils.mask_string(item, masked_value_set)
if item != org: if item != org:
output.remove(org) output.remove(org)
output.insert(orgIndex, item) output.insert(orgIndex, item)
if type(input) == types.StringType: if isinstance(input, types.StringType):
output = utils.mask_string(input, masked_value_set) output = utils.mask_string(input, masked_value_set)
return output return output
@ -312,7 +313,7 @@ def _handleGroupCondition(config, conditionName, conditionValue):
# If the condition is a string - just read it to global conf # If the condition is a string - just read it to global conf
# We assume that if we get a string as a member it is the name of a member of conf_params # We assume that if we get a string as a member it is the name of a member of conf_params
elif type(conditionName) == types.StringType: elif isinstance(conditionName, types.StringType):
conditionValue = _loadParamFromFile(config, "general", conditionName) conditionValue = _loadParamFromFile(config, "general", conditionName)
else: else:
# Any other type is invalid # Any other type is invalid
@ -410,9 +411,9 @@ def _handleAnswerFileParams(answerFile):
# Handle post condition match for group # Handle post condition match for group
if postConditionValue != group.POST_CONDITION_MATCH: if postConditionValue != group.POST_CONDITION_MATCH:
logging.error("The group condition (%s) returned: %s, which differs from the excpeted output: %s" %\ logging.error("The group condition (%s) returned: %s, which differs from the excpeted output: %s" %
(group.GROUP_NAME, postConditionValue, group.POST_CONDITION_MATCH)) (group.GROUP_NAME, postConditionValue, group.POST_CONDITION_MATCH))
raise ValueError(output_messages.ERR_EXP_GROUP_VALIDATION_ANS_FILE %\ raise ValueError(output_messages.ERR_EXP_GROUP_VALIDATION_ANS_FILE %
(group.GROUP_NAME, postConditionValue, group.POST_CONDITION_MATCH)) (group.GROUP_NAME, postConditionValue, group.POST_CONDITION_MATCH))
else: else:
logging.debug("condition (%s) passed" % group.POST_CONDITION) logging.debug("condition (%s) passed" % group.POST_CONDITION)
@ -523,9 +524,9 @@ def _handleParams(configFile):
def _getConditionValue(matchMember): def _getConditionValue(matchMember):
returnValue = False returnValue = False
if type(matchMember) == types.FunctionType: if isinstance(matchMember, types.FunctionType):
returnValue = matchMember(controller.CONF) returnValue = matchMember(controller.CONF)
elif type(matchMember) == types.StringType: elif isinstance(matchMember, types.StringType):
# we assume that if we get a string as a member it is the name # we assume that if we get a string as a member it is the name
# of a member of conf_params # of a member of conf_params
if not controller.CONF.has_key(matchMember): if not controller.CONF.has_key(matchMember):
@ -875,9 +876,9 @@ def loadPlugins():
checkPlugin(moduleobj) checkPlugin(moduleobj)
controller.addPlugin(moduleobj) controller.addPlugin(moduleobj)
except: except:
logging.error("Failed to load plugin from file %s", item) logging.error("Failed to load plugin from file %s", item)
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
raise Exception("Failed to load plugin from file %s" % item) raise Exception("Failed to load plugin from file %s" % item)
def checkPlugin(plugin): def checkPlugin(plugin):

View File

@ -21,7 +21,7 @@ class Controller(object):
MESSAGES = [] MESSAGES = []
CONF = {} CONF = {}
__single = None # the one, true Singleton ... for god's sake why ??? :) __single = None # the one, true Singleton ... for god's sake why ??? :)
def __new__(self, *args, **kwargs): def __new__(self, *args, **kwargs):
""" """

View File

@ -33,6 +33,6 @@ commands = python setup.py build_sphinx
# E123, E125 skipped as they are invalid PEP-8. # E123, E125 skipped as they are invalid PEP-8.
# #
# All other checks should be enabled in the future. # All other checks should be enabled in the future.
ignore = E123,E125,H803,E128,F403,F821,E127,F811,F841,E501,E111,E502,W601,E721,E261,E131,E126,E303,E241,E713,E122,E401,H402,H302,H303,H304,H301,H306,H234,H405,H404,H904,H201,H305,H307,H501,H102,H233,H101,H233,H401,H232 ignore = E123,E125,H803,E128,F403,F821,E127,F811,F841,E501,W601,E131,E126,E303,E122,H402,H302,H303,H304,H301,H306,H234,H405,H404,H904,H201,H305,H307,H501,H102,H233,H101,H233,H401,H232
show-source = True show-source = True
exclude=.venv,.git,.tox exclude=.venv,.git,.tox