From b3f42a89201a90bd555d65e3dd6891d525166e7b Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 6 Jul 2017 21:58:24 +0200 Subject: [PATCH] Fix some more test details. --- parso/python/normalizer.py | 9 +++++---- test/normalizer_issue_files/E12_first.py | 1 + test/normalizer_issue_files/E12_second.py | 12 +++++------- test/normalizer_issue_files/E12_third.py | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/parso/python/normalizer.py b/parso/python/normalizer.py index 4659ff0..cfe599d 100644 --- a/parso/python/normalizer.py +++ b/parso/python/normalizer.py @@ -21,6 +21,7 @@ _NEEDS_SPACE = ('=', '%', '->', '>>=', '**=', '//=') _NEEDS_SPACE += _BITWISE_OPERATOR _IMPLICIT_INDENTATION_TYPES = ('dictorsetmaker', 'argument') +_POSSIBLE_SLICE_PARENTS = ('subscript', 'subscriptlist', 'sliceop') class CompressNormalizer(Normalizer): """ @@ -428,7 +429,7 @@ class PEP8Normalizer(Normalizer): + self._config.indentation: self.add_issue(129, "Line with same indent as next logical block", leaf) elif indentation != should_be_indentation: - if not self._check_tabs_spaces(spacing): + if not self._check_tabs_spaces(spacing) and leaf.value != '\n': if value in '])}': if node.type == IndentationTypes.VERTICAL_BRACKET: self.add_issue(124, "Closing bracket does not match visual indentation", leaf) @@ -550,13 +551,13 @@ class PEP8Normalizer(Normalizer): message = "Whitespace before '%s'" % leaf.value add_if_spaces(202, message, spacing) elif leaf in (',', ';') or leaf == ':' \ - and leaf.parent.type not in ('subscript', 'subscriptlist'): + and leaf.parent.type not in _POSSIBLE_SLICE_PARENTS: message = "Whitespace before '%s'" % leaf.value add_if_spaces(203, message, spacing) - elif prev == ':' and prev.parent.type in ('subscript', 'subscriptlist'): + elif prev == ':' and prev.parent.type in _POSSIBLE_SLICE_PARENTS: pass # TODO elif prev in (',', ';', ':'): - add_not_spaces('231', "missing whitespace after '%s'", spacing) + add_not_spaces(231, "missing whitespace after '%s'", spacing) elif leaf == ':': # Is a subscript # TODO pass diff --git a/test/normalizer_issue_files/E12_first.py b/test/normalizer_issue_files/E12_first.py index 52bff7a..f36382f 100644 --- a/test/normalizer_issue_files/E12_first.py +++ b/test/normalizer_issue_files/E12_first.py @@ -66,6 +66,7 @@ abricot = 3 + \ print "hello", ( "there", + #: E126:5 # "john", "dude") part = set_mimetype(( diff --git a/test/normalizer_issue_files/E12_second.py b/test/normalizer_issue_files/E12_second.py index fffda78..6370a3a 100644 --- a/test/normalizer_issue_files/E12_second.py +++ b/test/normalizer_issue_files/E12_second.py @@ -39,9 +39,7 @@ setup('', ]) -#TODO -##: W291 -#: E123+2:4 +#: E123+2:4 E291:15 print "E123", ( "bad", "hanging", "close" ) @@ -117,15 +115,15 @@ def long_function_name( def qualify_by_address( - #: E129 + #: E129:4 E129+1:4 self, cr, uid, ids, context=None, - #: E129 params_to_check=frozenset(QUALIF_BY_ADDRESS_PARAM)): """ This gets called by the web server """ + + +#: E129+1:4 E129+2:4 if (a == 2 or - #: E129 b == "abc def ghi" - #: E129 "jkl mno"): return True diff --git a/test/normalizer_issue_files/E12_third.py b/test/normalizer_issue_files/E12_third.py index f7ab8db..288ec51 100644 --- a/test/normalizer_issue_files/E12_third.py +++ b/test/normalizer_issue_files/E12_third.py @@ -79,12 +79,12 @@ if True: return [node.copy( #: E121:12 ( - #: E121 + #: E121:16 E126+1:24 E126+2:24 replacement # First, look at all the node's current children. for child in node.children - #: E121 for replacement in replace(child) + #: E123 ), dict(name=token.undefined) )] @@ -105,7 +105,7 @@ print dedent( mkdir -p ./{build}/ mv ./build/ ./{build}/%(revision)s/ '''.format( - #: E121:4 E123+2:0 + #: E121:4 E121+1:4 E123+2:0 build='build', # more stuff )