Skip to content

Commit

Permalink
update for new release of pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Jul 16, 2018
1 parent 4f9d0bd commit 60a8ae1
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,no-self-use,too-many-arguments,too-many-locals,too-many-branches,invalid-name,min-public-methods,too-few-public-methods,C0325,I0011,duplicate-code,too-many-statements,line-too-long
disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,no-self-use,too-many-arguments,too-many-locals,too-many-branches,invalid-name,min-public-methods,too-few-public-methods,C0325,I0011,duplicate-code,too-many-statements,line-too-long,useless-object-inheritance,bad-option-value



Expand Down
23 changes: 12 additions & 11 deletions src/cfnlint/cfn_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def CfnJSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook,
if object_hook is not None:
pairs = object_hook(pairs, s)
return pairs, end + 1
elif nextchar != '"':

if nextchar != '"':
raise JSONDecodeError('Expecting property name enclosed in double quotes', s, end)
end += 1
while True:
Expand Down Expand Up @@ -336,17 +337,17 @@ def _scan_once(string, idx):

if nextchar == '"':
return parse_string(string, idx + 1, strict)
elif nextchar == '{':
if nextchar == '{':
return parse_object(
(string, idx + 1), strict,
scan_once, object_hook, object_pairs_hook, memo)
elif nextchar == '[':
if nextchar == '[':
return parse_array((string, idx + 1), _scan_once)
elif nextchar == 'n' and string[idx:idx + 4] == 'null':
if nextchar == 'n' and string[idx:idx + 4] == 'null':
return None, idx + 4
elif nextchar == 't' and string[idx:idx + 4] == 'true':
if nextchar == 't' and string[idx:idx + 4] == 'true':
return True, idx + 4
elif nextchar == 'f' and string[idx:idx + 5] == 'false':
if nextchar == 'f' and string[idx:idx + 5] == 'false':
return False, idx + 5

m = match_number(string, idx)
Expand All @@ -357,14 +358,14 @@ def _scan_once(string, idx):
else:
res = parse_int(integer)
return res, m.end()
elif nextchar == 'N' and string[idx:idx + 3] == 'NaN':
if nextchar == 'N' and string[idx:idx + 3] == 'NaN':
return parse_constant('NaN'), idx + 3
elif nextchar == 'I' and string[idx:idx + 8] == 'Infinity':
if nextchar == 'I' and string[idx:idx + 8] == 'Infinity':
return parse_constant('Infinity'), idx + 8
elif nextchar == '-' and string[idx:idx + 9] == '-Infinity':
if nextchar == '-' and string[idx:idx + 9] == '-Infinity':
return parse_constant('-Infinity'), idx + 9
else:
raise StopIteration(idx)

raise StopIteration(idx)

def scan_once(string, idx):
""" Scan Once"""
Expand Down
6 changes: 3 additions & 3 deletions src/cfnlint/cfn_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ def construct_getatt(node):

if isinstance(node.value, (six.text_type, six.string_types)):
return node.value.split('.')
elif isinstance(node.value, list):
if isinstance(node.value, list):
return [s.value for s in node.value]
else:
raise ValueError('Unexpected node type: {}'.format(type(node.value)))

raise ValueError('Unexpected node type: {}'.format(type(node.value)))

def load(filename):
"""
Expand Down
8 changes: 4 additions & 4 deletions src/cfnlint/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import six
from yaml.parser import ParserError, ScannerError
from cfnlint import RulesCollection, Match
import cfnlint.formatters as formatters
import cfnlint.formatters
import cfnlint.cfn_yaml
import cfnlint.cfn_json
import cfnlint.maintenance
Expand Down Expand Up @@ -172,12 +172,12 @@ def get_formatter(fmt):
formatter = {}
if fmt:
if fmt == 'quiet':
formatter = formatters.QuietFormatter()
formatter = cfnlint.formatters.QuietFormatter()
elif fmt == 'parseable':
# pylint: disable=bad-option-value
formatter = formatters.ParseableFormatter()
formatter = cfnlint.formatters.ParseableFormatter()
else:
formatter = formatters.Formatter()
formatter = cfnlint.formatters.Formatter()

return formatter

Expand Down
4 changes: 2 additions & 2 deletions src/cfnlint/rules/mappings/Used.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def match(self, cfn):
'Disabling check %s', self.id
)
return matches
else:
findinmap_mappings.append(maptree[-1][0])

findinmap_mappings.append(maptree[-1][0])
else:
findinmap_mappings.append(maptree[-1])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ def check_first_stage(self, stages, path):
"""Validate the first stage of a pipeline has source actions."""
matches = []

if len(stages) < 1:
if len(stages) < 1: # pylint: disable=C1801
self.logger.debug('Stages was empty. Should have been caught by generic linting.')
return matches

# pylint: disable=R1718
first_stage = set([a.get('ActionTypeId').get('Category') for a in stages[0]['Actions']])
if first_stage and 'Source' not in first_stage:
message = 'The first stage of a pipeline must contain at least one source action.'
Expand All @@ -60,7 +61,7 @@ def check_source_actions(self, stages, path):
matches = []
categories = set()

if len(stages) < 1:
if len(stages) < 1: # pylint: disable=C1801
self.logger.debug('Stages was empty. Should have been caught by generic linting.')
return matches

Expand Down
2 changes: 1 addition & 1 deletion src/cfnlint/rules/resources/properties/Properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def primitivetypecheck(self, value, primtype, proppath):
matches = list()
if isinstance(value, dict) and primtype == 'Json':
return matches
elif isinstance(value, dict):
if isinstance(value, dict):
if len(value) == 1:
for sub_key, sub_value in value.items():
if sub_key in cfnlint.helpers.CONDITION_FUNCTIONS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def check_primitive_type(self, value, item_type, path):

if isinstance(value, dict) and item_type == 'Json':
return matches
elif item_type in ['String']:
if item_type in ['String']:
if not isinstance(value, (str, six.text_type, six.string_types)):
message = 'Property %s should be of type String' % ('/'.join(map(str, path)))
matches.append(RuleMatch(path, message))
Expand Down

0 comments on commit 60a8ae1

Please sign in to comment.